pub trait ByteConversion {
// Required methods
fn to_bytes_be(&self) -> Vec<u8> ⓘ;
fn to_bytes_le(&self) -> Vec<u8> ⓘ;
fn from_bytes_be(bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized;
fn from_bytes_le(bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized;
}
Expand description
A trait for converting an element to and from its byte representation and for getting an element from its byte representation in big-endian or little-endian order.
Required Methods§
Sourcefn to_bytes_be(&self) -> Vec<u8> ⓘ
fn to_bytes_be(&self) -> Vec<u8> ⓘ
Returns the byte representation of the element in big-endian order.}
Sourcefn to_bytes_le(&self) -> Vec<u8> ⓘ
fn to_bytes_le(&self) -> Vec<u8> ⓘ
Returns the byte representation of the element in little-endian order.
Sourcefn from_bytes_be(bytes: &[u8]) -> Result<Self, ByteConversionError>where
Self: Sized,
fn from_bytes_be(bytes: &[u8]) -> Result<Self, ByteConversionError>where
Self: Sized,
Returns the element from its byte representation in big-endian order.
Sourcefn from_bytes_le(bytes: &[u8]) -> Result<Self, ByteConversionError>where
Self: Sized,
fn from_bytes_le(bytes: &[u8]) -> Result<Self, ByteConversionError>where
Self: Sized,
Returns the element from its byte representation in little-endian order.