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.
Implementations on Foreign Types§
Source§impl ByteConversion for u32
impl ByteConversion for u32
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,
Source§impl ByteConversion for u64
impl ByteConversion for u64
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,
Source§impl ByteConversion for [FieldElement<Babybear31PrimeField>; 4]
impl ByteConversion for [FieldElement<Babybear31PrimeField>; 4]
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,
Source§impl ByteConversion for [FieldElement<Babybear31PrimeField>; 4]
impl ByteConversion for [FieldElement<Babybear31PrimeField>; 4]
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,
Source§impl<F> ByteConversion for [FieldElement<F>; 2]where
F: IsField,
impl<F> ByteConversion for [FieldElement<F>; 2]where
F: IsField,
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,
Source§impl<F> ByteConversion for [FieldElement<F>; 3]where
F: IsField,
impl<F> ByteConversion for [FieldElement<F>; 3]where
F: IsField,
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,
Implementors§
impl ByteConversion for FieldElement<Degree2ExtensionField>
impl ByteConversion for FieldElement<Degree2ExtensionField>
impl ByteConversion for FieldElement<Degree2ExtensionField>
Available on crate feature
alloc
only.