snarkvm_console::prelude

Trait FromBits

Source
pub trait FromBits: Sized {
    // Required methods
    fn from_bits_le(bits: &[bool]) -> Result<Self, Error>;
    fn from_bits_be(bits: &[bool]) -> Result<Self, Error>;
}

Required Methods§

Source

fn from_bits_le(bits: &[bool]) -> Result<Self, Error>

Reads Self from a boolean array in little-endian order.

Source

fn from_bits_be(bits: &[bool]) -> Result<Self, Error>

Reads Self from a boolean array in big-endian order.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<E> FromBits for Address<E>
where E: Environment,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Address<E>, Error>

Initializes a new address by recovering the x-coordinate of an affine group from a list of little-endian bits.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Address<E>, Error>

Initializes a new address by recovering the x-coordinate of an affine group from a list of big-endian bits.

Source§

impl<E> FromBits for Boolean<E>
where E: Environment,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Boolean<E>, Error>

Initializes a new boolean by extracting the first bit from a list of length 1.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Boolean<E>, Error>

Initializes a new boolean by extracting the first bit from a list of length 1.

Source§

impl<E> FromBits for Field<E>
where E: Environment,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Field<E>, Error>

Initializes a new field from a list of little-endian bits.

  • If bits_le is longer than E::Field::size_in_bits(), the excess bits are enforced to be 0s.
  • If bits_le is shorter than E::Field::size_in_bits(), it is padded with 0s up to field size.
Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Field<E>, Error>

Initializes a new field from a list of big-endian bits without leading zeros.

Source§

impl<E> FromBits for Group<E>
where E: Environment,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Group<E>, Error>

Initializes a new group by recovering the x-coordinate of an affine group from a list of little-endian bits.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Group<E>, Error>

Initializes a new group by recovering the x-coordinate of an affine group from a list of big-endian bits.

Source§

impl<E> FromBits for Scalar<E>
where E: Environment,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Scalar<E>, Error>

Initializes a new scalar from a list of little-endian bits.

  • If bits_le is longer than E::Scalar::size_in_bits(), the excess bits are enforced to be 0s.
  • If bits_le is shorter than E::Scalar::size_in_bits(), it is padded with 0s up to scalar size.
Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Scalar<E>, Error>

Initializes a new scalar from a list of big-endian bits without leading zeros.

Source§

impl<E, I> FromBits for Integer<E, I>
where E: Environment, I: IntegerType,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Integer<E, I>, Error>

Initializes a new integer from a list of little-endian bits.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Integer<E, I>, Error>

Initializes a new integer from a list of big-endian bits.

Source§

impl<N> FromBits for Plaintext<N>
where N: Network,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Plaintext<N>, Error>

Initializes a new plaintext from a list of little-endian bits without trailing zeros.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Plaintext<N>, Error>

Initializes a new plaintext from a list of big-endian bits without trailing zeros.

Source§

impl<N> FromBits for ComputeKey<N>
where N: Network,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<ComputeKey<N>, Error>

Initializes a new compute key from a list of little-endian bits.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<ComputeKey<N>, Error>

Initializes a new compute key from a list of big-endian bits.

Source§

impl<N> FromBits for Signature<N>
where N: Network,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Signature<N>, Error>

Initializes a new signature from a list of little-endian bits.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Signature<N>, Error>

Initializes a new signature from a list of big-endian bits.

Source§

impl<N> FromBits for Ciphertext<N>
where N: Network,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Ciphertext<N>, Error>

Returns this ciphertext as a list of little-endian bits.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Ciphertext<N>, Error>

Returns this ciphertext as a list of big-endian bits.

Source§

impl<N> FromBits for Identifier<N>
where N: Network,

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Identifier<N>, Error>

Initializes a new identifier from a list of little-endian bits without trailing zeros.

Source§

fn from_bits_be(bits_be: &[bool]) -> Result<Identifier<N>, Error>

Initializes a new identifier from a list of big-endian bits without leading zeros.

Implementors§