Module: Kobako::Wire::Codec
- Defined in:
- lib/kobako/wire/codec.rb,
lib/kobako/wire/codec/error.rb,
lib/kobako/wire/codec/decoder.rb,
lib/kobako/wire/codec/encoder.rb,
lib/kobako/wire/codec/factory.rb
Overview
Host-side MessagePack codec for the kobako wire contract — the byte-level layer (SPEC.md → Wire Codec). The envelope layer (Kobako::Wire::Envelope) sits on top of this and pins the four logical message shapes (Request / Response / Result / Panic).
Backed by the official msgpack gem via Factory; Encoder and Decoder are thin wrappers that register the three kobako-specific ext types (0x00 Symbol, 0x01 Capability Handle, 0x02 Exception envelope) on a single MessagePack::Factory instance. The Rust side mirrors this layer as the codec module in the kobako-wasm crate; the ext-code constants live as module-private values on Factory alongside codec::EXT_SYMBOL / codec::EXT_HANDLE / codec::EXT_ERRENV on that side.
Defined Under Namespace
Modules: Decoder, Encoder, Factory Classes: Error, InvalidEncoding, InvalidType, Truncated, UnsupportedType
Class Method Summary collapse
-
.translate_value_object_error ⇒ Object
Wire-boundary translator: every wire Value Object (Handle / Exception / Request / Response / Panic / Outcome) raises
ArgumentErrorwhen an invariant is violated at construction.
Class Method Details
.translate_value_object_error ⇒ Object
Wire-boundary translator: every wire Value Object (Handle / Exception / Request / Response / Panic / Outcome) raises ArgumentError when an invariant is violated at construction. The wire boundary surfaces those violations to callers as InvalidType so the public taxonomy stays Codec::Error and never leaks ArgumentError from the Ruby standard library.
Wrap any block that constructs a wire Value Object from decoded bytes with this helper to keep the five decode sites (Request / Response / Panic / Handle ext / Exception ext) uniform. Do not use it for general-purpose validation outside the wire boundary — host-layer ArgumentError values should propagate unchanged.
33 34 35 36 37 |
# File 'lib/kobako/wire/codec.rb', line 33 def self.translate_value_object_error yield rescue ::ArgumentError => e raise InvalidType, e. end |