rama::tls::boring::dep::boring::bn

Struct BigNum

pub struct BigNum(/* private fields */);
Expand description

Dynamically sized large number impelementation

Perform large number mathematics. Create a new BigNum with new. Perform standard mathematics on large numbers using methods from Dref<Target = BigNumRef>

OpenSSL documentation at BN_new.

§Examples

use boring::bn::BigNum;
let little_big = BigNum::from_u32(std::u32::MAX)?;
assert_eq!(*&little_big.num_bytes(), 4);

Implementations§

§

impl BigNum

pub fn new() -> Result<BigNum, ErrorStack>

Creates a new BigNum with the value 0.

This corresponds to BN_new.

pub fn from_u32(n: u32) -> Result<BigNum, ErrorStack>

Creates a new BigNum with the given value.

This corresponds to BN_set_word.

pub fn from_dec_str(s: &str) -> Result<BigNum, ErrorStack>

Creates a BigNum from a decimal string.

This corresponds to BN_dec2bn.

pub fn from_hex_str(s: &str) -> Result<BigNum, ErrorStack>

Creates a BigNum from a hexadecimal string.

This corresponds to BN_hex2bn.

pub fn from_slice(n: &[u8]) -> Result<BigNum, ErrorStack>

Creates a new BigNum from an unsigned, big-endian encoded number of arbitrary length.

OpenSSL documentation at BN_bin2bn

let bignum = BigNum::from_slice(&[0x12, 0x00, 0x34]).unwrap();

assert_eq!(bignum, BigNum::from_u32(0x120034).unwrap());

This corresponds to BN_bin2bn.

Methods from Deref<Target = BigNumRef>§

pub fn clear(&mut self)

Erases the memory used by this BigNum, resetting its value to 0.

This can be used to destroy sensitive data such as keys when they are no longer needed.

This corresponds to BN_clear.

pub fn add_word(&mut self, w: u32) -> Result<(), ErrorStack>

Adds a u32 to self.

This corresponds to BN_add_word.

pub fn sub_word(&mut self, w: u32) -> Result<(), ErrorStack>

Subtracts a u32 from self.

This corresponds to BN_sub_word.

pub fn mul_word(&mut self, w: u32) -> Result<(), ErrorStack>

Multiplies a u32 by self.

This corresponds to BN_mul_word.

pub fn div_word(&mut self, w: u32) -> Result<u64, ErrorStack>

Divides self by a u32, returning the remainder.

This corresponds to BN_div_word.

pub fn mod_word(&self, w: u32) -> Result<u64, ErrorStack>

Returns the result of self modulo w.

This corresponds to BN_mod_word.

pub fn rand_range(&self, rnd: &mut BigNumRef) -> Result<(), ErrorStack>

Places a cryptographically-secure pseudo-random nonnegative number less than self in rnd.

This corresponds to BN_rand_range.

pub fn pseudo_rand_range(&self, rnd: &mut BigNumRef) -> Result<(), ErrorStack>

The cryptographically weak counterpart to rand_in_range.

This corresponds to BN_pseudo_rand_range.

pub fn set_bit(&mut self, n: i32) -> Result<(), ErrorStack>

Sets bit n. Equivalent to self |= (1 << n).

When setting a bit outside of self, it is expanded.

This corresponds to BN_set_bit.

pub fn clear_bit(&mut self, n: i32) -> Result<(), ErrorStack>

Clears bit n, setting it to 0. Equivalent to self &= ~(1 << n).

When clearing a bit outside of self, an error is returned.

This corresponds to BN_clear_bit.

pub fn is_bit_set(&self, n: i32) -> bool

Returns true if the nth bit of self is set to 1, false otherwise.

This corresponds to BN_is_bit_set.

pub fn mask_bits(&mut self, n: i32) -> Result<(), ErrorStack>

Truncates self to the lowest n bits.

An error occurs if self is already shorter than n bits.

This corresponds to BN_mask_bits.

pub fn lshift1(&mut self, a: &BigNumRef) -> Result<(), ErrorStack>

Places a << 1 in self. Equivalent to self * 2.

This corresponds to BN_lshift1.

pub fn rshift1(&mut self, a: &BigNumRef) -> Result<(), ErrorStack>

Places a >> 1 in self. Equivalent to self / 2.

This corresponds to BN_rshift1.

pub fn checked_add( &mut self, a: &BigNumRef, b: &BigNumRef, ) -> Result<(), ErrorStack>

Places a + b in self. core::ops::Add is also implemented for BigNumRef.

This corresponds to BN_add.

pub fn checked_sub( &mut self, a: &BigNumRef, b: &BigNumRef, ) -> Result<(), ErrorStack>

Places a - b in self. core::ops::Sub is also implemented for BigNumRef.

This corresponds to BN_sub.

pub fn lshift(&mut self, a: &BigNumRef, n: i32) -> Result<(), ErrorStack>

Places a << n in self. Equivalent to a * 2 ^ n.

This corresponds to BN_lshift.

pub fn rshift(&mut self, a: &BigNumRef, n: i32) -> Result<(), ErrorStack>

Places a >> n in self. Equivalent to a / 2 ^ n.

This corresponds to BN_rshift.

pub fn to_owned(&self) -> Result<BigNum, ErrorStack>

Creates a new BigNum with the same value.

This corresponds to BN_dup.

pub fn set_negative(&mut self, negative: bool)

Sets the sign of self. Pass true to set self to a negative. False sets self positive.

This corresponds to BN_set_negative.

pub fn ucmp(&self, oth: &BigNumRef) -> Ordering

Compare the absolute values of self and oth.

§Examples
let s = -BigNum::from_u32(8).unwrap();
let o = BigNum::from_u32(8).unwrap();

assert_eq!(s.ucmp(&o), Ordering::Equal);

This corresponds to BN_ucmp.

pub fn is_negative(&self) -> bool

Returns true if self is negative.

This corresponds to BN_is_negative.

pub fn num_bits(&self) -> i32

Returns the number of significant bits in self.

This corresponds to BN_num_bits.

pub fn num_bytes(&self) -> i32

Returns the size of self in bytes. Implemented natively.

pub fn rand( &mut self, bits: i32, msb: MsbOption, odd: bool, ) -> Result<(), ErrorStack>

Generates a cryptographically strong pseudo-random BigNum, placing it in self.

§Parameters
  • bits: Length of the number in bits.
  • msb: The desired properties of the most significant bit. See constants.
  • odd: If true, the generated number will be odd.
§Examples
use boring::bn::{BigNum, MsbOption};
use boring::error::ErrorStack;

fn generate_random() -> Result< BigNum, ErrorStack > {
   let mut big = BigNum::new()?;

   // Generates a 128-bit odd random number
   big.rand(128, MsbOption::MAYBE_ZERO, true);
   Ok((big))
}

This corresponds to BN_rand.

pub fn pseudo_rand( &mut self, bits: i32, msb: MsbOption, odd: bool, ) -> Result<(), ErrorStack>

The cryptographically weak counterpart to rand. Not suitable for key generation.

This corresponds to BN_pseudo_rand.

pub fn generate_prime( &mut self, bits: i32, safe: bool, add: Option<&BigNumRef>, rem: Option<&BigNumRef>, ) -> Result<(), ErrorStack>

Generates a prime number, placing it in self.

§Parameters
  • bits: The length of the prime in bits (lower bound).
  • safe: If true, returns a “safe” prime p so that (p-1)/2 is also prime.
  • add/rem: If add is set to Some(add), p % add == rem will hold, where p is the generated prime and rem is 1 if not specified (None).
§Examples
use boring::bn::BigNum;
use boring::error::ErrorStack;

fn generate_weak_prime() -> Result< BigNum, ErrorStack > {
   let mut big = BigNum::new()?;

   // Generates a 128-bit simple prime number
   big.generate_prime(128, false, None, None);
   Ok((big))
}

This corresponds to BN_generate_prime_ex.

pub fn checked_mul( &mut self, a: &BigNumRef, b: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of a * b in self. core::ops::Mul is also implemented for BigNumRef.

This corresponds to BN_mul.

pub fn checked_div( &mut self, a: &BigNumRef, b: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of a / b in self. The remainder is discarded. core::ops::Div is also implemented for BigNumRef.

This corresponds to BN_div.

pub fn checked_rem( &mut self, a: &BigNumRef, b: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of a % b in self.

This corresponds to BN_div.

pub fn div_rem( &mut self, rem: &mut BigNumRef, a: &BigNumRef, b: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of a / b in self and a % b in rem.

This corresponds to BN_div.

pub fn sqr( &mut self, a: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of in self.

This corresponds to BN_sqr.

pub fn nnmod( &mut self, a: &BigNumRef, m: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of a mod m in self. As opposed to div_rem the result is non-negative.

This corresponds to BN_nnmod.

pub fn mod_add( &mut self, a: &BigNumRef, b: &BigNumRef, m: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of (a + b) mod m in self.

This corresponds to BN_mod_add.

pub fn mod_sub( &mut self, a: &BigNumRef, b: &BigNumRef, m: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of (a - b) mod m in self.

This corresponds to BN_mod_sub.

pub fn mod_mul( &mut self, a: &BigNumRef, b: &BigNumRef, m: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of (a * b) mod m in self.

This corresponds to BN_mod_mul.

pub fn mod_sqr( &mut self, a: &BigNumRef, m: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of a² mod m in self.

This corresponds to BN_mod_sqr.

pub fn exp( &mut self, a: &BigNumRef, p: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of a^p in self.

This corresponds to BN_exp.

pub fn mod_exp( &mut self, a: &BigNumRef, p: &BigNumRef, m: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the result of a^p mod m in self.

This corresponds to BN_mod_exp.

pub fn mod_inverse( &mut self, a: &BigNumRef, n: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the inverse of a modulo n in self.

This corresponds to BN_mod_inverse.

pub fn gcd( &mut self, a: &BigNumRef, b: &BigNumRef, ctx: &mut BigNumContextRef, ) -> Result<(), ErrorStack>

Places the greatest common denominator of a and b in self.

This corresponds to BN_gcd.

pub fn is_prime( &self, checks: i32, ctx: &mut BigNumContextRef, ) -> Result<bool, ErrorStack>

Checks whether self is prime.

Performs a Miller-Rabin probabilistic primality test with checks iterations.

§Return Value

Returns true if self is prime with an error probability of less than 0.25 ^ checks.

This corresponds to BN_is_prime_ex.

pub fn is_prime_fasttest( &self, checks: i32, ctx: &mut BigNumContextRef, do_trial_division: bool, ) -> Result<bool, ErrorStack>

Checks whether self is prime with optional trial division.

If do_trial_division is true, first performs trial division by a number of small primes. Then, like is_prime, performs a Miller-Rabin probabilistic primality test with checks iterations.

§Return Value

Returns true if self is prime with an error probability of less than 0.25 ^ checks.

This corresponds to BN_is_prime_fasttest_ex.

pub fn to_vec(&self) -> Vec<u8>

Returns a big-endian byte vector representation of the absolute value of self.

self can be recreated by using from_slice.

let s = -BigNum::from_u32(4543).unwrap();
let r = BigNum::from_u32(4543).unwrap();

let s_vec = s.to_vec();
assert_eq!(BigNum::from_slice(&s_vec).unwrap(), r);

This corresponds to BN_bn2bin.

pub fn to_vec_padded(&self, pad_to: usize) -> Result<Vec<u8>, ErrorStack>

Returns a big-endian byte vector representation of the absolute value of self padded to pad_to bytes.

If pad_to is less than self.num_bytes() then an error is returned.

self can be recreated by using from_slice.

let bn = BigNum::from_u32(0x4543).unwrap();

let bn_vec = bn.to_vec_padded(4).unwrap();
assert_eq!(&bn_vec, &[0, 0, 0x45, 0x43]);

let r = bn.to_vec_padded(1);
assert!(r.is_err());

let bn = -BigNum::from_u32(0x4543).unwrap();
let bn_vec = bn.to_vec_padded(4).unwrap();
assert_eq!(&bn_vec, &[0, 0, 0x45, 0x43]);

pub fn to_dec_str(&self) -> Result<OpensslString, ErrorStack>

Returns a decimal string representation of self.

let s = -BigNum::from_u32(12345).unwrap();

assert_eq!(&**s.to_dec_str().unwrap(), "-12345");

This corresponds to BN_bn2dec.

pub fn to_hex_str(&self) -> Result<OpensslString, ErrorStack>

Returns a hexadecimal string representation of self.

let s = -BigNum::from_u32(0x99ff).unwrap();

assert_eq!(&**s.to_hex_str().unwrap(), "-99ff");

This corresponds to BN_bn2hex.

pub fn to_asn1_integer(&self) -> Result<Asn1Integer, ErrorStack>

Returns an Asn1Integer containing the value of self.

This corresponds to BN_to_ASN1_INTEGER.

Trait Implementations§

§

impl<'a, 'b> Add<&'b BigNum> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the + operator.
§

fn add(self, oth: &BigNum) -> BigNum

Performs the + operation. Read more
§

impl<'a, 'b> Add<&'b BigNum> for &'a BigNumRef

§

type Output = BigNum

The resulting type after applying the + operator.
§

fn add(self, oth: &BigNum) -> BigNum

Performs the + operation. Read more
§

impl<'a, 'b> Add<&'b BigNumRef> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the + operator.
§

fn add(self, oth: &BigNumRef) -> BigNum

Performs the + operation. Read more
§

impl AsMut<BigNumRef> for BigNum

§

fn as_mut(&mut self) -> &mut BigNumRef

Converts this type into a mutable reference of the (usually inferred) input type.
§

impl AsRef<BigNumRef> for BigNum

§

fn as_ref(&self) -> &BigNumRef

Converts this type into a shared reference of the (usually inferred) input type.
§

impl Borrow<BigNumRef> for BigNum

§

fn borrow(&self) -> &BigNumRef

Immutably borrows from an owned value. Read more
§

impl BorrowMut<BigNumRef> for BigNum

§

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

Mutably borrows from an owned value. Read more
§

impl Debug for BigNum

§

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

Formats the value using the given formatter. Read more
§

impl Deref for BigNum

§

type Target = BigNumRef

The resulting type after dereferencing.
§

fn deref(&self) -> &BigNumRef

Dereferences the value.
§

impl DerefMut for BigNum

§

fn deref_mut(&mut self) -> &mut BigNumRef

Mutably dereferences the value.
§

impl Display for BigNum

§

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

Formats the value using the given formatter. Read more
§

impl<'a, 'b> Div<&'b BigNum> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the / operator.
§

fn div(self, oth: &BigNum) -> BigNum

Performs the / operation. Read more
§

impl<'a, 'b> Div<&'b BigNum> for &'a BigNumRef

§

type Output = BigNum

The resulting type after applying the / operator.
§

fn div(self, oth: &BigNum) -> BigNum

Performs the / operation. Read more
§

impl<'a, 'b> Div<&'b BigNumRef> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the / operator.
§

fn div(self, oth: &BigNumRef) -> BigNum

Performs the / operation. Read more
§

impl Drop for BigNum

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl ForeignType for BigNum

§

type CType = bignum_st

The raw C type.
§

type Ref = BigNumRef

The type representing a reference to this type.
§

unsafe fn from_ptr(ptr: *mut bignum_st) -> BigNum

Constructs an instance of this type from its raw type. Read more
§

fn as_ptr(&self) -> *mut bignum_st

Returns a raw pointer to the wrapped value.
source§

fn into_ptr(self) -> *mut Self::CType

Consumes the wrapper and returns the raw pointer.
§

impl<'a, 'b> Mul<&'b BigNum> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the * operator.
§

fn mul(self, oth: &BigNum) -> BigNum

Performs the * operation. Read more
§

impl<'a, 'b> Mul<&'b BigNum> for &'a BigNumRef

§

type Output = BigNum

The resulting type after applying the * operator.
§

fn mul(self, oth: &BigNum) -> BigNum

Performs the * operation. Read more
§

impl<'a, 'b> Mul<&'b BigNumRef> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the * operator.
§

fn mul(self, oth: &BigNumRef) -> BigNum

Performs the * operation. Read more
§

impl Neg for &BigNum

§

type Output = BigNum

The resulting type after applying the - operator.
§

fn neg(self) -> BigNum

Performs the unary - operation. Read more
§

impl Neg for BigNum

§

type Output = BigNum

The resulting type after applying the - operator.
§

fn neg(self) -> BigNum

Performs the unary - operation. Read more
§

impl Ord for BigNum

§

fn cmp(&self, oth: &BigNum) -> Ordering

This method returns an Ordering between self and other. Read more
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
§

impl PartialEq<BigNum> for BigNumRef

§

fn eq(&self, oth: &BigNum) -> 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.
§

impl PartialEq<BigNumRef> for BigNum

§

fn eq(&self, oth: &BigNumRef) -> 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.
§

impl PartialEq for BigNum

§

fn eq(&self, oth: &BigNum) -> 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.
§

impl PartialOrd<BigNum> for BigNumRef

§

fn partial_cmp(&self, oth: &BigNum) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
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
§

impl PartialOrd<BigNumRef> for BigNum

§

fn partial_cmp(&self, oth: &BigNumRef) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
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
§

impl PartialOrd for BigNum

§

fn partial_cmp(&self, oth: &BigNum) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
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
§

impl<'a, 'b> Rem<&'b BigNum> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the % operator.
§

fn rem(self, oth: &BigNum) -> BigNum

Performs the % operation. Read more
§

impl<'a, 'b> Rem<&'b BigNum> for &'a BigNumRef

§

type Output = BigNum

The resulting type after applying the % operator.
§

fn rem(self, oth: &BigNum) -> BigNum

Performs the % operation. Read more
§

impl<'a, 'b> Rem<&'b BigNumRef> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the % operator.
§

fn rem(self, oth: &BigNumRef) -> BigNum

Performs the % operation. Read more
§

impl Shl<i32> for &BigNum

§

type Output = BigNum

The resulting type after applying the << operator.
§

fn shl(self, n: i32) -> BigNum

Performs the << operation. Read more
§

impl Shr<i32> for &BigNum

§

type Output = BigNum

The resulting type after applying the >> operator.
§

fn shr(self, n: i32) -> BigNum

Performs the >> operation. Read more
§

impl<'a, 'b> Sub<&'b BigNum> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the - operator.
§

fn sub(self, oth: &BigNum) -> BigNum

Performs the - operation. Read more
§

impl<'a, 'b> Sub<&'b BigNum> for &'a BigNumRef

§

type Output = BigNum

The resulting type after applying the - operator.
§

fn sub(self, oth: &BigNum) -> BigNum

Performs the - operation. Read more
§

impl<'a, 'b> Sub<&'b BigNumRef> for &'a BigNum

§

type Output = BigNum

The resulting type after applying the - operator.
§

fn sub(self, oth: &BigNumRef) -> BigNum

Performs the - operation. Read more
§

impl Eq for BigNum

§

impl Send for BigNum

§

impl Sync for BigNum

Auto Trait Implementations§

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
§

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

§

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

Compare self to key and return their ordering.
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

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

§

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

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

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

§

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

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

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

§

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

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

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

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

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<S, P, B, E>(self, other: P) -> And<T, P>
where T: Policy<S, B, E>, P: Policy<S, B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<S, P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<S, B, E>, P: Policy<S, B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T