Skip to main content

CapnpWire

Trait CapnpWire 

Source
pub trait CapnpWire: WireValue + Sized {
    // Required methods
    fn capnp_encode(&self) -> Result<Vec<u8>, CodecError>;
    fn capnp_decode(bytes: &[u8]) -> Result<Self, CodecError>;
}
Expand description

Per-message-type Cap’n Proto encode/decode contract.

Implementors typically build a capnp::message::Builder inside capnp_encode, populate it through the type’s generated builder API, and write it out via capnp::serialize::write_message. capnp_decode parses the inverse path through capnp::serialize::read_message.

Required Methods§

Source

fn capnp_encode(&self) -> Result<Vec<u8>, CodecError>

Serialise self into a fully-framed Cap’n Proto message.

Source

fn capnp_decode(bytes: &[u8]) -> Result<Self, CodecError>

Parse a fully-framed Cap’n Proto message back into Self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§