Struct crypto_bigint::Checked

source ·
pub struct Checked<T>(pub CtOption<T>);
Expand description

Provides intentionally-checked arithmetic on T.

Internally this leverages the CtOption type from the subtle crate in order to handle overflows.

Tuple Fields§

§0: CtOption<T>

Implementations§

source§

impl<T> Checked<T>

source

pub fn new(val: T) -> Self

Create a new checked arithmetic wrapper for the given value.

Trait Implementations§

source§

impl Add<&Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the + operation. Read more
source§

impl Add<&Checked<Limb>> for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the + operation. Read more
source§

impl<const LIMBS: usize> Add<&Checked<Uint<LIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the + operation. Read more
source§

impl<const LIMBS: usize> Add<&Checked<Uint<LIMBS>>> for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the + operation. Read more
source§

impl Add<Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Checked<Limb>) -> Checked<Limb>

Performs the + operation. Read more
source§

impl<const LIMBS: usize> Add<Checked<Uint<LIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the + operation. Read more
source§

impl Add for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Checked<Limb>

Performs the + operation. Read more
source§

impl<const LIMBS: usize> Add for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Checked<Uint<LIMBS>>

Performs the + operation. Read more
source§

impl AddAssign<&Checked<Limb>> for Checked<Limb>

source§

fn add_assign(&mut self, other: &Self)

Performs the += operation. Read more
source§

impl<const LIMBS: usize> AddAssign<&Checked<Uint<LIMBS>>> for Checked<Uint<LIMBS>>

source§

fn add_assign(&mut self, other: &Self)

Performs the += operation. Read more
source§

impl AddAssign for Checked<Limb>

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl<const LIMBS: usize> AddAssign for Checked<Uint<LIMBS>>

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl<T: Clone> Clone for Checked<T>

source§

fn clone(&self) -> Checked<T>

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<T: ConditionallySelectable> ConditionallySelectable for Checked<T>

source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
source§

impl<T: ConstantTimeEq> ConstantTimeEq for Checked<T>

source§

fn ct_eq(&self, rhs: &Self) -> Choice

Determine if two items are equal. Read more
source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
source§

impl<T: Debug> Debug for Checked<T>

source§

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

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

impl<T> Default for Checked<T>where T: Default,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, T: Default + Deserialize<'de>> Deserialize<'de> for Checked<T>

Available on crate feature serde only.
source§

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

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> From<Checked<T>> for CtOption<T>

source§

fn from(checked: Checked<T>) -> CtOption<T>

Converts to this type from the input type.
source§

impl<T> From<Checked<T>> for Option<T>

source§

fn from(checked: Checked<T>) -> Option<T>

Converts to this type from the input type.
source§

impl<T> From<CtOption<T>> for Checked<T>

source§

fn from(ct_option: CtOption<T>) -> Checked<T>

Converts to this type from the input type.
source§

impl Mul<&Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the * operation. Read more
source§

impl Mul<&Checked<Limb>> for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the * operation. Read more
source§

impl<const LIMBS: usize, const HLIMBS: usize> Mul<&Checked<Uint<HLIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Checked<Uint<HLIMBS>>) -> Checked<Uint<LIMBS>>

Performs the * operation. Read more
source§

impl<const LIMBS: usize, const HLIMBS: usize> Mul<&Checked<Uint<HLIMBS>>> for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Checked<Uint<HLIMBS>>) -> Checked<Uint<LIMBS>>

Performs the * operation. Read more
source§

impl Mul<Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Checked<Limb>) -> Checked<Limb>

Performs the * operation. Read more
source§

impl<const LIMBS: usize, const HLIMBS: usize> Mul<Checked<Uint<HLIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Checked<Uint<HLIMBS>>) -> Checked<Uint<LIMBS>>

Performs the * operation. Read more
source§

impl<const LIMBS: usize, const HLIMBS: usize> Mul<Checked<Uint<HLIMBS>>> for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Checked<Uint<HLIMBS>>) -> Checked<Uint<LIMBS>>

Performs the * operation. Read more
source§

impl Mul for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Checked<Limb>

Performs the * operation. Read more
source§

impl MulAssign<&Checked<Limb>> for Checked<Limb>

source§

fn mul_assign(&mut self, other: &Self)

Performs the *= operation. Read more
source§

impl<const LIMBS: usize, const HLIMBS: usize> MulAssign<&Checked<Uint<HLIMBS>>> for Checked<Uint<LIMBS>>

source§

fn mul_assign(&mut self, other: &Checked<Uint<HLIMBS>>)

Performs the *= operation. Read more
source§

impl<const LIMBS: usize, const HLIMBS: usize> MulAssign<Checked<Uint<HLIMBS>>> for Checked<Uint<LIMBS>>

source§

fn mul_assign(&mut self, other: Checked<Uint<HLIMBS>>)

Performs the *= operation. Read more
source§

impl MulAssign for Checked<Limb>

source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
source§

impl<T: Copy + Serialize> Serialize for Checked<T>

Available on crate feature serde only.
source§

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

Serialize this value into the given Serde serializer. Read more
source§

impl Sub<&Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the - operation. Read more
source§

impl Sub<&Checked<Limb>> for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the - operation. Read more
source§

impl<const LIMBS: usize> Sub<&Checked<Uint<LIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the - operation. Read more
source§

impl<const LIMBS: usize> Sub<&Checked<Uint<LIMBS>>> for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the - operation. Read more
source§

impl Sub<Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Checked<Limb>) -> Checked<Limb>

Performs the - operation. Read more
source§

impl<const LIMBS: usize> Sub<Checked<Uint<LIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the - operation. Read more
source§

impl Sub for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Checked<Limb>

Performs the - operation. Read more
source§

impl<const LIMBS: usize> Sub for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Checked<Uint<LIMBS>>

Performs the - operation. Read more
source§

impl SubAssign<&Checked<Limb>> for Checked<Limb>

source§

fn sub_assign(&mut self, other: &Self)

Performs the -= operation. Read more
source§

impl<const LIMBS: usize> SubAssign<&Checked<Uint<LIMBS>>> for Checked<Uint<LIMBS>>

source§

fn sub_assign(&mut self, other: &Self)

Performs the -= operation. Read more
source§

impl SubAssign for Checked<Limb>

source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
source§

impl<const LIMBS: usize> SubAssign for Checked<Uint<LIMBS>>

source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
source§

impl<T: Copy> Copy for Checked<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Checked<T>where T: RefUnwindSafe,

§

impl<T> Send for Checked<T>where T: Send,

§

impl<T> Sync for Checked<T>where T: Sync,

§

impl<T> Unpin for Checked<T>where T: Unpin,

§

impl<T> UnwindSafe for Checked<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,