Skip to main content

BytesRepr

Trait BytesRepr 

Source
pub trait BytesRepr {
    type Ctx;

    const MAX_LEN: usize;
    const SIZE: Option<usize>;

    // Required methods
    fn serialize(text: &[u8], buf: &mut Vec<u8>);
    fn deserialize<'de>(
        ctx: Self::Ctx,
        buf: &mut ParseBuf<'de>,
    ) -> Result<Cow<'de, [u8]>>;
}
Expand description

Representation of a serialized bytes.

Required Associated Constants§

Source

const MAX_LEN: usize

Maximum length of bytes for this repr (depends on how lenght is stored).

Source

const SIZE: Option<usize>

Required Associated Types§

Required Methods§

Source

fn serialize(text: &[u8], buf: &mut Vec<u8>)

Source

fn deserialize<'de>( ctx: Self::Ctx, buf: &mut ParseBuf<'de>, ) -> Result<Cow<'de, [u8]>>

Implementation must check the length of the buffer if Self::SIZE.is_none().

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§