Skip to main content

FlatbuffersWire

Trait FlatbuffersWire 

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

Per-message-type FlatBuffers encode/decode contract.

The trait deliberately does not bound T on any flatbuffers::Follow / flatbuffers::Push shape: those traits model the on-wire view of a flatbuffer table, not the owned Rust representation that travels through the codec API. Implementors build a flatbuffers::FlatBufferBuilder inside flatbuffers_encode and finish it; flatbuffers_decode reads the fields back into an owned Self (the codec returns Box<dyn ErasedWireValue>, which is necessarily owned).

Required Methods§

Source

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

Serialise self into a finished, root-prefixed flatbuffer.

Source

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

Parse a finished, root-prefixed flatbuffer back into Self.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§