heed

Trait BytesEncode

Source
pub trait BytesEncode<'a> {
    type EItem: 'a + ?Sized;

    // Required method
    fn bytes_encode(
        item: &'a Self::EItem,
    ) -> Result<Cow<'a, [u8]>, Box<dyn Error + Send + Sync>>;
}
Expand description

A trait that represents an encoding structure.

Required Associated Types§

Source

type EItem: 'a + ?Sized

The type to encode.

Required Methods§

Source

fn bytes_encode( item: &'a Self::EItem, ) -> Result<Cow<'a, [u8]>, Box<dyn Error + Send + Sync>>

Encode the given item as bytes.

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.

Implementations on Foreign Types§

Source§

impl BytesEncode<'_> for Str

Source§

type EItem = str

Source§

fn bytes_encode( item: &<Str as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl BytesEncode<'_> for Unit

Source§

type EItem = ()

Source§

fn bytes_encode( _item: &<Unit as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl BytesEncode<'_> for I8

Source§

type EItem = i8

Source§

fn bytes_encode( item: &<I8 as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl BytesEncode<'_> for U8

Source§

type EItem = u8

Source§

fn bytes_encode( item: &<U8 as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<'a> BytesEncode<'a> for Bytes

Source§

type EItem = [u8]

Source§

fn bytes_encode( item: &'a <Bytes as BytesEncode<'a>>::EItem, ) -> Result<Cow<'a, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<'a, T> BytesEncode<'a> for SerdeBincode<T>
where T: 'a + Serialize,

Source§

type EItem = T

Source§

fn bytes_encode( item: &'a <SerdeBincode<T> as BytesEncode<'a>>::EItem, ) -> Result<Cow<'a, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<'a, T> BytesEncode<'a> for SerdeJson<T>
where T: 'a + Serialize,

Source§

type EItem = T

Source§

fn bytes_encode( item: &<SerdeJson<T> as BytesEncode<'a>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<O> BytesEncode<'_> for I16<O>
where O: ByteOrder,

Source§

type EItem = i16

Source§

fn bytes_encode( item: &<I16<O> as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<O> BytesEncode<'_> for I32<O>
where O: ByteOrder,

Source§

type EItem = i32

Source§

fn bytes_encode( item: &<I32<O> as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<O> BytesEncode<'_> for I64<O>
where O: ByteOrder,

Source§

type EItem = i64

Source§

fn bytes_encode( item: &<I64<O> as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<O> BytesEncode<'_> for I128<O>
where O: ByteOrder,

Source§

type EItem = i128

Source§

fn bytes_encode( item: &<I128<O> as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<O> BytesEncode<'_> for U16<O>
where O: ByteOrder,

Source§

type EItem = u16

Source§

fn bytes_encode( item: &<U16<O> as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<O> BytesEncode<'_> for U32<O>
where O: ByteOrder,

Source§

type EItem = u32

Source§

fn bytes_encode( item: &<U32<O> as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<O> BytesEncode<'_> for U64<O>
where O: ByteOrder,

Source§

type EItem = u64

Source§

fn bytes_encode( item: &<U64<O> as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Source§

impl<O> BytesEncode<'_> for U128<O>
where O: ByteOrder,

Source§

type EItem = u128

Source§

fn bytes_encode( item: &<U128<O> as BytesEncode<'_>>::EItem, ) -> Result<Cow<'_, [u8]>, Box<dyn Error + Send + Sync>>

Implementors§