Skip to main content

BytesEncode

Trait BytesEncode 

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

    // Required method
    fn bytes_encode(item: &'a Self::EItem) -> Result<Cow<'a, [u8]>, EncodeError>;
}
Expand description

A trait that represents an encoding structure.

Required Associated Types§

Source

type EItem: ?Sized + 'a

The type to encode

Required Methods§

Source

fn bytes_encode(item: &'a Self::EItem) -> Result<Cow<'a, [u8]>, EncodeError>

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".

Implementations on Foreign Types§

Source§

impl BytesEncode<'_> for &[u8]

Source§

type EItem = [u8]

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for &str

Source§

type EItem = str

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for String

Source§

type EItem = str

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for Vec<u8>

Source§

type EItem = [u8]

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for bool

Source§

impl BytesEncode<'_> for i16

Encodable version of i16 (Little Endian).

Source§

type EItem = i16

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for i32

Encodable version of i32 (Little Endian).

Source§

type EItem = i32

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for i64

Encodable version of i64 (Little Endian).

Source§

type EItem = i64

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for i128

Encodable version of i128 (Little Endian).

Source§

impl BytesEncode<'_> for u8

Source§

type EItem = u8

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for u16

Encodable version of u16 (Little Endian).

Source§

type EItem = u16

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for u32

Encodable version of u32 (Little Endian).

Source§

type EItem = u32

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for u64

Encodable version of u64 (Little Endian).

Source§

type EItem = u64

Source§

fn bytes_encode(item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Source§

impl BytesEncode<'_> for u128

Encodable version of u128 (Little Endian).

Source§

impl BytesEncode<'static> for ()

Source§

type EItem = ()

Source§

fn bytes_encode(_item: &Self::EItem) -> Result<Cow<'_, [u8]>, EncodeError>

Implementors§