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§
Sourcefn packed_len(&self) -> usize
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
.
Sourcefn unpack_bytes_verified<T: AsRef<[u8]>>(
bytes: T,
visitor: &Self::UnpackVisitor,
) -> Result<Self, UnpackError<<Self as Packable>::UnpackError, UnexpectedEOF>>
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.
Sourcefn unpack_bytes_unverified<T: AsRef<[u8]>>(
bytes: T,
) -> 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>>
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", so this trait is not object safe.