Skip to main content

PackableExt

Trait PackableExt 

Source
pub trait PackableExt: Packable {
    // Required methods
    fn packed_len(&self) -> usize;
    fn pack_to_vec(&self) -> Vec<u8> ;
    fn unpack_bytes_verified<T: AsRef<[u8]>>(
        bytes: T,
        visitor: &Self::UnpackVisitor,
    ) -> Result<Self, UnpackError<<Self as Packable>::UnpackError, UnexpectedEOF>>;
    fn unpack_bytes_unverified<T: AsRef<[u8]>>(
        bytes: T,
    ) -> Result<Self, UnpackError<<Self as Packable>::UnpackError, UnexpectedEOF>>;
}
Expand description

Extension trait for types that implement Packable.

Required Methods§

Source

fn packed_len(&self) -> usize

Returns the length in bytes of the value after being packed. The returned value always matches the number of bytes written using pack.

Source

fn pack_to_vec(&self) -> Vec<u8>

Convenience method that packs this value into a Vec<u8>.

Source

fn unpack_bytes_verified<T: AsRef<[u8]>>( bytes: T, visitor: &Self::UnpackVisitor, ) -> Result<Self, UnpackError<<Self as Packable>::UnpackError, UnexpectedEOF>>

Unpacks this value from a sequence of bytes doing syntactical checks.

Source

fn unpack_bytes_unverified<T: AsRef<[u8]>>( bytes: T, ) -> Result<Self, UnpackError<<Self as Packable>::UnpackError, UnexpectedEOF>>

Unpacks this value from a sequence of bytes without doing syntactical checks.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§