Module: Kobako::Codec
- Defined in:
- lib/kobako/codec.rb,
lib/kobako/codec/error.rb,
lib/kobako/codec/state.rb,
lib/kobako/codec/utils.rb,
lib/kobako/codec/decoder.rb,
lib/kobako/codec/encoder.rb,
lib/kobako/codec/ext_types.rb,
lib/kobako/codec/handle_walk.rb,
sig/kobako/codec.rbs,
sig/kobako/codec/error.rbs,
sig/kobako/codec/state.rbs,
sig/kobako/codec/utils.rbs,
sig/kobako/codec/decoder.rbs,
sig/kobako/codec/encoder.rbs,
sig/kobako/codec/ext_types.rbs,
sig/kobako/codec/handle_walk.rbs
Overview
Host-side MessagePack codec for the kobako wire contract — the
byte-level layer (docs/wire-codec.md).
Two consumers sit on top:
Kobako::Transport pins the host↔guest framing (Request / Response /
Run / Yield) and Kobako::Outcome owns the per-+#run+ outcome
envelope (Result body / Panic map). The ext-type leaves this layer
carries — Kobako::Handle (0x01) and Kobako::Fault (0x02) — live at
the kobako root so the codec can register them without depending
upward on Transport.
Backed by the official msgpack gem: ExtTypes registers the three
kobako-specific ext types (0x00 Symbol, 0x01 Capability Handle,
0x02 Exception envelope) on one process-wide MessagePack::Factory,
and Encoder / Decoder are thin wrappers over it. The Rust side
mirrors this layer as the codec module in the kobako-codec crate;
the ext-code constants live as module-private values on ExtTypes
alongside codec::EXT_SYMBOL / codec::EXT_HANDLE /
codec::EXT_ERRENV on that side.
Defined Under Namespace
Modules: Decoder, Encoder, ExtTypes, HandleWalk, Utils, _HandleTable Classes: Error, InvalidEncoding, InvalidType, Truncated, UnsupportedType
Constant Summary collapse
- FACTORY =
The process-wide registered factory: ext registration is paid once at load, and a registered
MessagePack::Factoryonly reads its type registry afterwards, so every thread shares this instance for byte work. ExtTypes.build_factory
Class Method Summary collapse
-
.forbid_faults(&block) ⇒ void
Bracket a codec operation in a payload position: an ext 0x02 Fault envelope is only legal in the Response fault field, so the envelope layers open this bracket around every other encode / decode and the ext-type conversions refuse the envelope while it is open — a wire violation on decode, no wire representation on encode.
-
.track_handles(&block) ⇒ void
Bracket a decode and return the block's result together with whether the decoded tree carried an ext 0x01 Capability Handle — the signal a dispatch path uses to skip an all-identity Handle-resolution walk.
Class Method Details
.forbid_faults(&block) ⇒ void
This method returns an undefined value.
Bracket a codec operation in a payload position: an ext 0x02 Fault envelope is only legal in the Response fault field, so the envelope layers open this bracket around every other encode / decode and the ext-type conversions refuse the envelope while it is open — a wire violation on decode, no wire representation on encode.
44 45 46 |
# File 'lib/kobako/codec.rb', line 44 def self.forbid_faults(&block) State.current.forbid_faults(&block) end |
.track_handles(&block) ⇒ void
This method returns an undefined value.
Bracket a decode and return the block's result together with whether the decoded tree carried an ext 0x01 Capability Handle — the signal a dispatch path uses to skip an all-identity Handle-resolution walk. The tracking state is codec-internal; this is its only readout.
35 36 37 |
# File 'lib/kobako/codec.rb', line 35 def self.track_handles(&block) State.current.track_handles(&block) end |