snarkvm_console_types_field

Struct Field

Source
pub struct Field<E: Environment> { /* private fields */ }

Implementations§

Source§

impl<E: Environment> Field<E>

Source

pub fn even_square_root(&self) -> Result<Self>

Returns the square_root of self, where the least significant bit of the square root is zero.

Source§

impl<E: Environment> Field<E>

Source

pub const SIZE_IN_BITS: usize = <E::Field>::SIZE_IN_BITS

The field size in bits.

Source

pub const SIZE_IN_BYTES: usize = _

The field size in bytes.

Source

pub const SIZE_IN_DATA_BITS: usize = <E::Field>::SIZE_IN_DATA_BITS

The field capacity for data bits.

Source

pub const fn new(field: E::Field) -> Self

Initializes a new field.

Source

pub fn new_domain_separator(domain: &str) -> Self

Initializes a new field as a domain separator.

Source

pub fn from_u8(value: u8) -> Self

Initializes a new field from a u8.

Source

pub fn from_u16(value: u16) -> Self

Initializes a new field from a u16.

Source

pub fn from_u32(value: u32) -> Self

Initializes a new field from a u32.

Source

pub fn from_u64(value: u64) -> Self

Initializes a new field from a u64.

Source

pub fn from_u128(value: u128) -> Self

Initializes a new field from a u128.

Source

pub fn half() -> Self

Returns 1 * 2^{-1}.

Trait Implementations§

Source§

impl<E: Environment> Add<&Field<E>> for Field<E>

Source§

fn add(self, other: &Field<E>) -> Self::Output

Returns the sum of self and other.

Source§

type Output = Field<E>

The resulting type after applying the + operator.
Source§

impl<E: Environment> Add for Field<E>

Source§

fn add(self, other: Field<E>) -> Self::Output

Returns the sum of self and other.

Source§

type Output = Field<E>

The resulting type after applying the + operator.
Source§

impl<E: Environment> AddAssign<&Field<E>> for Field<E>

Source§

fn add_assign(&mut self, other: &Field<E>)

Adds other to self.

Source§

impl<E: Environment> AddAssign for Field<E>

Source§

fn add_assign(&mut self, other: Field<E>)

Adds other to self.

Source§

impl<E: Clone + Environment> Clone for Field<E>
where E::Field: Clone,

Source§

fn clone(&self) -> Field<E>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: Environment> Compare for Field<E>

Source§

fn is_less_than(&self, other: &Self) -> Self::Output

Returns true if self is less than other.

Source§

fn is_greater_than(&self, other: &Self) -> Self::Output

Returns true if self is greater than other.

Source§

fn is_less_than_or_equal(&self, other: &Self) -> Self::Output

Returns true if self is less than or equal to other.

Source§

fn is_greater_than_or_equal(&self, other: &Self) -> Self::Output

Returns true if self is greater than or equal to other.

Source§

type Output = Boolean<E>

Source§

impl<E: Environment> Debug for Field<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: Environment> Default for Field<E>

Source§

fn default() -> Self

Returns the default field element.

Source§

impl<E: Environment> Deref for Field<E>

Source§

type Target = <E as Environment>::Field

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<E: Environment> DerefMut for Field<E>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de, E: Environment> Deserialize<'de> for Field<E>

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserializes the field from a string or bytes.

Source§

impl<E: Environment> Display for Field<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: Environment> Distribution<Field<E>> for Standard

Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Field<E>

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
Source§

impl<E: Environment> Div<&Field<E>> for Field<E>

Source§

fn div(self, other: &Field<E>) -> Self::Output

Returns the quotient of self and other.

Source§

type Output = Field<E>

The resulting type after applying the / operator.
Source§

impl<E: Environment> Div for Field<E>

Source§

fn div(self, other: Field<E>) -> Self::Output

Returns the quotient of self and other.

Source§

type Output = Field<E>

The resulting type after applying the / operator.
Source§

impl<E: Environment> DivAssign<&Field<E>> for Field<E>

Source§

fn div_assign(&mut self, other: &Field<E>)

Divides self by other.

Source§

impl<E: Environment> DivAssign for Field<E>

Source§

fn div_assign(&mut self, other: Field<E>)

Divides self by other.

Source§

impl<E: Environment> Double for Field<E>

Source§

fn double(&self) -> Self::Output

Returns the double of self.

Source§

type Output = Field<E>

Source§

impl<E: Environment> Equal for Field<E>

Source§

fn is_equal(&self, other: &Self) -> Self::Output

Returns true if self and other are equal.

Source§

fn is_not_equal(&self, other: &Self) -> Self::Output

Returns true if self and other are not equal.

Source§

type Output = Boolean<E>

Source§

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

Source§

fn from_bits_le(bits_le: &[bool]) -> Result<Self>

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<Self>

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

Source§

impl<E: Environment> FromBytes for Field<E>

Source§

fn read_le<R: Read>(reader: R) -> IoResult<Self>

Reads the field from a buffer.

Source§

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

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

impl<E: Environment> FromStr for Field<E>

Source§

fn from_str(string: &str) -> Result<Self>

Parses a string into a field.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl<E: Hash + Environment> Hash for Field<E>
where E::Field: Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<E: Environment> Inverse for Field<E>

Source§

fn inverse(&self) -> Result<Self::Output>

Returns the inverse of self.

Source§

type Output = Field<E>

Source§

impl<E: Environment> Mul<&Field<E>> for Field<E>

Source§

fn mul(self, other: &Field<E>) -> Self::Output

Returns the product of self and other.

Source§

type Output = Field<E>

The resulting type after applying the * operator.
Source§

impl<E: Environment> Mul for Field<E>

Source§

fn mul(self, other: Field<E>) -> Self::Output

Returns the product of self and other.

Source§

type Output = Field<E>

The resulting type after applying the * operator.
Source§

impl<E: Environment> MulAssign<&Field<E>> for Field<E>

Source§

fn mul_assign(&mut self, other: &Field<E>)

Multiplies self by other.

Source§

impl<E: Environment> MulAssign for Field<E>

Source§

fn mul_assign(&mut self, other: Field<E>)

Multiplies self by other.

Source§

impl<E: Environment> Neg for Field<E>

Source§

fn neg(self) -> Self::Output

Returns the negation of self.

Source§

type Output = Field<E>

The resulting type after applying the - operator.
Source§

impl<E: Environment> One for Field<E>

Source§

fn one() -> Self

Returns the 1 element of the field.

Source§

fn is_one(&self) -> bool

Returns true if the element is one.

Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

impl<E: Environment> Ord for Field<E>

Source§

fn cmp(&self, other: &Self) -> Ordering

Returns the lexicographic ordering of self and other.

1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<E: Environment> Parser for Field<E>

Source§

fn parse(string: &str) -> ParserResult<'_, Self>

Parses a string into a field circuit.

Source§

impl<E: PartialEq + Environment> PartialEq for Field<E>
where E::Field: PartialEq,

Source§

fn eq(&self, other: &Field<E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E: Environment> PartialOrd for Field<E>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

Returns the lexicographic ordering of self and other.

1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<E: Environment> Pow<&Field<E>> for Field<E>

Source§

fn pow(self, other: &Field<E>) -> Self::Output

Returns the power of self to the power of other.

Source§

type Output = Field<E>

The result after applying the operator.
Source§

impl<E: Environment> Pow<Field<E>> for Field<E>

Source§

fn pow(self, other: Field<E>) -> Self::Output

Returns the power of self to the power of other.

Source§

type Output = Field<E>

The result after applying the operator.
Source§

impl<'a, E: Environment> Product<&'a Field<E>> for Field<E>

Source§

fn product<I: Iterator<Item = &'a Field<E>>>(iter: I) -> Self

Returns the product of self and other.

Source§

impl<E: Environment> Product for Field<E>

Source§

fn product<I: Iterator<Item = Field<E>>>(iter: I) -> Self

Returns the product of self and other.

Source§

impl<E: Environment> Serialize for Field<E>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serializes the field into a string or as bytes.

Source§

impl<E: Environment> SizeInBits for Field<E>

Source§

fn size_in_bits() -> usize

Returns the field size in bits.

Source§

impl<E: Environment> SizeInBytes for Field<E>

Source§

fn size_in_bytes() -> usize

Returns the field size in bytes.

Source§

impl<E: Environment> SizeInDataBits for Field<E>

Source§

fn size_in_data_bits() -> usize

Returns the field capacity for data bits.

Source§

impl<E: Environment> Square for Field<E>

Source§

fn square(&self) -> Self::Output

Returns the square of self.

Source§

type Output = Field<E>

Source§

impl<E: Environment> SquareRoot for Field<E>

Source§

fn square_root(&self) -> Result<Self::Output>

Returns the square_root of self. If there are two square roots, the bitwise lesser one is returned.

Source§

type Output = Field<E>

Source§

impl<E: Environment> Sub<&Field<E>> for Field<E>

Source§

fn sub(self, other: &Field<E>) -> Self::Output

Returns the difference of self and other.

Source§

type Output = Field<E>

The resulting type after applying the - operator.
Source§

impl<E: Environment> Sub for Field<E>

Source§

fn sub(self, other: Field<E>) -> Self::Output

Returns the difference of self and other.

Source§

type Output = Field<E>

The resulting type after applying the - operator.
Source§

impl<E: Environment> SubAssign<&Field<E>> for Field<E>

Source§

fn sub_assign(&mut self, other: &Field<E>)

Subtracts other from self.

Source§

impl<E: Environment> SubAssign for Field<E>

Source§

fn sub_assign(&mut self, other: Field<E>)

Subtracts other from self.

Source§

impl<'a, E: Environment> Sum<&'a Field<E>> for Field<E>

Source§

fn sum<I: Iterator<Item = &'a Field<E>>>(iter: I) -> Self

Returns the sum of self and other.

Source§

impl<E: Environment> Sum for Field<E>

Source§

fn sum<I: Iterator<Item = Field<E>>>(iter: I) -> Self

Returns the sum of self and other.

Source§

impl<E: Environment> Ternary for Field<E>

Source§

fn ternary( condition: &Self::Boolean, first: &Self, second: &Self, ) -> Self::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Field<E>

Source§

impl<E: Environment> ToBits for Field<E>

Source§

fn write_bits_le(&self, vec: &mut Vec<bool>)

Outputs the little-endian bit representation of self without trailing zeros.

Source§

fn write_bits_be(&self, vec: &mut Vec<bool>)

Outputs the big-endian bit representation of self without leading zeros.

Source§

fn to_bits_le(&self) -> Vec<bool>

Returns self as a boolean array in little-endian order.
Source§

fn to_bits_be(&self) -> Vec<bool>

Returns self as a boolean array in big-endian order.
Source§

fn num_bits() -> Option<usize>

An optional indication of how many bits an object can be represented with.
Source§

impl<E: Environment> ToBytes for Field<E>

Source§

fn write_le<W: Write>(&self, writer: W) -> IoResult<()>

Writes the field to a buffer.

Source§

fn to_bytes_le(&self) -> Result<Vec<u8>, Error>
where Self: Sized,

Returns self as a byte array in little-endian order.
Source§

impl<E: Environment> TypeName for Field<E>

Source§

fn type_name() -> &'static str

Returns the type name as a string.

Source§

impl<E: Environment> Zero for Field<E>

Source§

fn zero() -> Self

Returns the 0 element of the field.

Source§

fn is_zero(&self) -> bool

Returns true if the element is zero.

Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl<E: Environment> Zeroize for Field<E>

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<E: Copy + Environment> Copy for Field<E>
where E::Field: Copy,

Source§

impl<E: Eq + Environment> Eq for Field<E>
where E::Field: Eq,

Source§

impl<E: Environment> FieldTrait for Field<E>

Source§

impl<E: Environment> StructuralPartialEq for Field<E>

Auto Trait Implementations§

§

impl<E> Freeze for Field<E>
where <E as Environment>::Field: Freeze,

§

impl<E> RefUnwindSafe for Field<E>

§

impl<E> Send for Field<E>

§

impl<E> Sync for Field<E>

§

impl<E> Unpin for Field<E>
where <E as Environment>::Field: Unpin,

§

impl<E> UnwindSafe for Field<E>
where <E as Environment>::Field: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<'de, T> DeserializeExt<'de> for T

Source§

fn take_from_value<D>( value: &mut Value, field: &str, ) -> Result<T, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Uniform for T

Source§

fn rand<R>(rng: &mut R) -> T
where R: Rng + ?Sized,

Samples a random value from a uniform distribution.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,