Skip to main content

FromBytes

Trait FromBytes 

Source
pub trait FromBytes {
    // Required method
    fn read_le<R>(reader: R) -> Result<Self, Error>
       where R: Read,
             Self: Sized;

    // Provided methods
    fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>
       where Self: Sized { ... }
    fn from_bytes_le_unchecked(bytes: &[u8]) -> Result<Self, Error>
       where Self: Sized { ... }
    fn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
       where R: Read,
             Self: Sized { ... }
    fn read_le_with_unchecked<R>(
        reader: R,
        unchecked: bool,
    ) -> Result<Self, Error>
       where R: Read,
             Self: Sized { ... }
}

Required Methods§

Source

fn read_le<R>(reader: R) -> Result<Self, Error>
where R: Read, Self: Sized,

Reads Self from reader as little-endian bytes.

Provided Methods§

Source

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

Returns Self from a byte array in little-endian order.

Source

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

Same behavior as Self::from_bytes_le but avoids costly checks. This shall only be called when deserializing from a trusted source, such as local storage.

Returns Self from a byte array in little-endian order.

Source

fn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
where R: Read, Self: Sized,

Same behavior as Self::read_le but avoids costly checks. This shall only be called when deserializing from a trusted source, such as local storage.

The default implementation simply calls Self::read_le.

Source

fn read_le_with_unchecked<R>(reader: R, unchecked: bool) -> Result<Self, Error>
where R: Read, Self: Sized,

Helper function that deserializes either unchecked or checked based on the given boolean flag.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromBytes for SocketAddr

Source§

fn read_le<R>(reader: R) -> Result<SocketAddr, Error>
where R: Read,

Source§

impl FromBytes for bool

Source§

fn read_le<R>(reader: R) -> Result<bool, Error>
where R: Read,

Source§

impl FromBytes for i8

Source§

fn read_le<R>(reader: R) -> Result<i8, Error>
where R: Read,

Source§

impl FromBytes for i16

Source§

fn read_le<R>(reader: R) -> Result<i16, Error>
where R: Read,

Source§

impl FromBytes for i32

Source§

fn read_le<R>(reader: R) -> Result<i32, Error>
where R: Read,

Source§

impl FromBytes for i64

Source§

fn read_le<R>(reader: R) -> Result<i64, Error>
where R: Read,

Source§

impl FromBytes for i128

Source§

fn read_le<R>(reader: R) -> Result<i128, Error>
where R: Read,

Source§

impl FromBytes for u8

Source§

fn read_le<R>(reader: R) -> Result<u8, Error>
where R: Read,

Source§

impl FromBytes for u16

Source§

fn read_le<R>(reader: R) -> Result<u16, Error>
where R: Read,

Source§

impl FromBytes for u32

Source§

fn read_le<R>(reader: R) -> Result<u32, Error>
where R: Read,

Source§

impl FromBytes for u64

Source§

fn read_le<R>(reader: R) -> Result<u64, Error>
where R: Read,

Source§

impl FromBytes for u128

Source§

fn read_le<R>(reader: R) -> Result<u128, Error>
where R: Read,

Source§

impl FromBytes for ()

Source§

fn read_le<R>(_bytes: R) -> Result<(), Error>
where R: Read,

Source§

impl<L, R> FromBytes for (L, R)
where L: FromBytes, R: FromBytes,

Source§

fn read_le<Reader>(reader: Reader) -> Result<(L, R), Error>
where Reader: Read,

Source§

impl<P> FromBytes for G1Prepared<P>
where P: Bls12Parameters,

Source§

fn read_le<R>(reader: R) -> Result<G1Prepared<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for G2Prepared<P>
where P: Bls12Parameters,

Source§

fn read_le<R>(reader: R) -> Result<G2Prepared<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for Affine<P>

Source§

fn read_le<R>(reader: R) -> Result<Affine<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for Projective<P>

Source§

fn read_le<R>(reader: R) -> Result<Projective<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for Affine<P>

Source§

fn read_le<R>(reader: R) -> Result<Affine<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for Projective<P>

Source§

fn read_le<R>(reader: R) -> Result<Projective<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for Fp2<P>
where P: Fp2Parameters,

Source§

fn read_le<R>(reader: R) -> Result<Fp2<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for Fp6<P>
where P: Fp6Parameters,

Source§

fn read_le<R>(reader: R) -> Result<Fp6<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for Fp12<P>
where P: Fp12Parameters,

Source§

fn read_le<R>(reader: R) -> Result<Fp12<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for Fp256<P>
where P: Fp256Parameters,

Source§

fn read_le<R>(reader: R) -> Result<Fp256<P>, Error>
where R: Read,

Source§

impl<P> FromBytes for Fp384<P>
where P: Fp384Parameters,

Source§

fn read_le<R>(reader: R) -> Result<Fp384<P>, Error>
where R: Read,

Source§

impl<const N: usize> FromBytes for [u8; N]

Source§

fn read_le<R>(reader: R) -> Result<[u8; N], Error>
where R: Read,

Source§

impl<const N: usize> FromBytes for [u16; N]

Source§

fn read_le<R>(reader: R) -> Result<[u16; N], Error>
where R: Read,

Source§

impl<const N: usize> FromBytes for [u32; N]

Source§

fn read_le<R>(reader: R) -> Result<[u32; N], Error>
where R: Read,

Source§

impl<const N: usize> FromBytes for [u64; N]

Source§

fn read_le<R>(reader: R) -> Result<[u64; N], Error>
where R: Read,

Implementors§