pub trait ScalarExt: Scalar {
// Provided methods
fn pow10(exponent: u8) -> Self { ... }
fn signed_cmp(&self, other: &Self) -> Ordering { ... }
fn from_wrapping(value: U256) -> Self { ... }
fn into_u256_wrapping(self) -> U256 { ... }
fn from_byte_slice_via_hash(bytes: &[u8]) -> Self { ... }
}
Expand description
Extension trait for blanket implementations for Scalar
types.
This trait is primarily to avoid cluttering the core Scalar
implementation with default implementations
and provides helper methods for Scalar
.
Provided Methods§
Sourcefn pow10(exponent: u8) -> Self
fn pow10(exponent: u8) -> Self
Compute 10^exponent for the Scalar. Note that we do not check for overflow.
Sourcefn signed_cmp(&self, other: &Self) -> Ordering
fn signed_cmp(&self, other: &Self) -> Ordering
Compare two Scalar
s as signed numbers.
Sourcefn from_wrapping(value: U256) -> Self
fn from_wrapping(value: U256) -> Self
Converts a U256 to Scalar, wrapping as needed
Sourcefn into_u256_wrapping(self) -> U256
fn into_u256_wrapping(self) -> U256
Converts a Scalar to U256. Note that any values above MAX_SIGNED
shall remain positive, even if they are representative of negative values.
Sourcefn from_byte_slice_via_hash(bytes: &[u8]) -> Self
fn from_byte_slice_via_hash(bytes: &[u8]) -> Self
Converts a byte slice to a Scalar using a hash function, preventing collisions.
WARNING: Only up to 31 bytes (2^248 bits) are supported by PoSQL
cryptographic
objects. This function masks off the last byte of the hash to ensure the result
fits in this range.
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.