Skip to main content

AirbenderCodec

Trait AirbenderCodec 

Source
pub trait AirbenderCodec {
    const VERSION: u32;

    // Required methods
    fn encode<T>(value: &T) -> Result<Vec<u8>, CodecError>
       where T: Serialize;
    fn decode<T>(bytes: &[u8]) -> Result<T, CodecError>
       where T: DeserializeOwned;
}
Expand description

A stable, versioned serializer used by Airbender host and guest programs.

Required Associated Constants§

Source

const VERSION: u32

Version identifier baked into manifests and tooling.

Required Methods§

Source

fn encode<T>(value: &T) -> Result<Vec<u8>, CodecError>
where T: Serialize,

Serialize a value into a byte payload.

Source

fn decode<T>(bytes: &[u8]) -> Result<T, CodecError>

Deserialize a value from a byte payload.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl AirbenderCodec for AirbenderCodecV0

Source§

const VERSION: u32 = AIRBENDER_CODEC_V0