Trait ConstantTimeResult

Source
pub trait ConstantTimeResult<T, E> {
    // Required methods
    fn ct_is_ok(&self) -> bool;
    fn ct_is_err(&self) -> bool;
    fn ct_map<U, F, G>(self, ok_fn: F, err_fn: G) -> U
       where F: FnOnce(T) -> U,
             G: FnOnce(E) -> U,
             U: ConditionallySelectable;
}
Expand description

Trait for checking if an operation succeeded in constant time

Required Methods§

Source

fn ct_is_ok(&self) -> bool

Check if this result is Ok, without branching on the result

Source

fn ct_is_err(&self) -> bool

Check if this result is Err, without branching on the result

Source

fn ct_map<U, F, G>(self, ok_fn: F, err_fn: G) -> U
where F: FnOnce(T) -> U, G: FnOnce(E) -> U, U: ConditionallySelectable,

Map a result to a value in constant time, calling a provided function regardless of whether the result is Ok or Err

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<T, E> ConstantTimeResult<T, E> for Result<T, E>

Source§

fn ct_is_ok(&self) -> bool

Source§

fn ct_is_err(&self) -> bool

Source§

fn ct_map<U, F, G>(self, ok_fn: F, err_fn: G) -> U
where F: FnOnce(T) -> U, G: FnOnce(E) -> U, U: ConditionallySelectable,

Implementors§