Trait 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§

Source

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

Returns the byte representation of the element in big-endian order.}

Source

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

Returns the byte representation of the element in little-endian order.

Source

fn from_bytes_be(bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Returns the element from its byte representation in big-endian order.

Source

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

Source§

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

Source§

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

Source§

fn from_bytes_be(_bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

fn from_bytes_le(_bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

impl ByteConversion for u64

Source§

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

Source§

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

Source§

fn from_bytes_be(_bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

fn from_bytes_le(_bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

impl ByteConversion for [FieldElement<Babybear31PrimeField>; 4]

Source§

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

Source§

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

Source§

fn from_bytes_be(bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

fn from_bytes_le(bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

impl ByteConversion for [FieldElement<Babybear31PrimeField>; 4]

Source§

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

Source§

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

Source§

fn from_bytes_be(bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

fn from_bytes_le(bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

impl<F> ByteConversion for [FieldElement<F>; 2]
where F: IsField,

Source§

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

Source§

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

Source§

fn from_bytes_be(_bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

fn from_bytes_le(_bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

impl<F> ByteConversion for [FieldElement<F>; 3]
where F: IsField,

Source§

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

Source§

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

Source§

fn from_bytes_be(_bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Source§

fn from_bytes_le(_bytes: &[u8]) -> Result<Self, ByteConversionError>
where Self: Sized,

Implementors§