Trait lambdaworks_math::traits::ByteConversion
source · 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.