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). This is the payload codec: the core envelope is framed natively, so what reaches here is one codec document — an invocation's arguments (+Kobako::Payload::Arguments+), a dispatch or yield value, or an invocation's value and a Panic's diagnostics (+Kobako::Outcome+). The ext-type leaves this layer carries — Kobako::Handle (0x01) — lives at the kobako root so the codec can register it without depending upward on Transport.

Backed by the official msgpack gem: ExtTypes registers the two kobako-specific ext types (0x00 Symbol, 0x01 Capability Handle) 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 on that side.

Defined Under Namespace

Modules: Decoder, Encoder, ExtTypes, HandleWalk, Utils, _HandleTable Classes: Error, InvalidEncodingError, InvalidTypeError, TruncatedInputError, UnsupportedTypeError

Constant Summary collapse

MAX_NESTING_DEPTH =

The maximum structural nesting depth the wire represents (the MessagePack ecosystem's bound), shared with the guest kobako_codec so both sides cap identically. The host→guest wrap walk refuses a #run argument nesting past it — a reference cycle necessarily does.

Returns:

  • (Integer)
128
FACTORY =

The process-wide registered factory: ext registration is paid once at load, and a registered MessagePack::Factory only reads its type registry afterwards, so every thread shares this instance for byte work.

Returns:

  • (MessagePack::Factory)
ExtTypes.build_factory

Class Method Summary collapse

Class Method Details

.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.



40
41
42
# File 'lib/kobako/codec.rb', line 40

def self.track_handles(&block)
  State.current.track_handles(&block)
end