Skip to main content

FfiFormat

Trait FfiFormat 

Source
pub trait FfiFormat: Debug + 'static {
    type Error: Error;

    // Required methods
    fn serialize<T: Serialize>(
        buffer: &mut Vec<u8>,
        value: &T,
    ) -> Result<(), Self::Error>;
    fn deserialize<'de, T: Deserialize<'de>>(
        bytes: &'de [u8],
    ) -> Result<T, Self::Error>;
}
Expand description

A serialization format for the bridge FFI.

Note: While you can implement your own format for use with the [BridgeWithSerializer], the type generation system doesn’t yet support automatically generating the shell-side support for different formats, and you’ll need to bring your own solution for this.

Required Associated Types§

Required Methods§

Source

fn serialize<T: Serialize>( buffer: &mut Vec<u8>, value: &T, ) -> Result<(), Self::Error>

Serialize an instance of T into the provided growable byte buffer.

§Errors

Returns an error if serialization fails.

Source

fn deserialize<'de, T: Deserialize<'de>>( bytes: &'de [u8], ) -> Result<T, Self::Error>

Deserialize an instance of T from the provided byte slice.

§Errors

Returns an error if deserialization fails.

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§