Skip to main content

ConstantTimeResult

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

Deprecated compatibility helpers for inspecting a Result.

These methods perform ordinary, data-dependent branching. Their historical ct_ prefix is inaccurate; use Result::is_ok, Result::is_err, or Result::map_or_else instead. No generic helper can make arbitrary closures and enum-variant control flow constant-time.

Required Methodsยง

Source

fn ct_is_ok(&self) -> bool

๐Ÿ‘ŽDeprecated:

ct_is_ok branches on the Result variant; use Result::is_ok and do not treat the variant as secret

Equivalent to Result::is_ok; this is not constant-time.

Source

fn ct_is_err(&self) -> bool

๐Ÿ‘ŽDeprecated:

ct_is_err branches on the Result variant; use Result::is_err and do not treat the variant as secret

Equivalent to Result::is_err; this is not constant-time.

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,

๐Ÿ‘ŽDeprecated:

ct_map invokes only the selected closure; use Result::map_or_else and do not treat the variant as secret

Map the selected variant; only one closure is called.

This is not constant-time. The ConditionallySelectable bound remains only to avoid breaking the legacy method signature.

Dyn Compatibilityยง

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Typesยง

Sourceยง

impl<T, E> ConstantTimeResult<T, E> for Result<T, E>

Sourceยง

fn ct_is_ok(&self) -> bool

๐Ÿ‘ŽDeprecated:

ct_is_ok branches on the Result variant; use Result::is_ok and do not treat the variant as secret

Sourceยง

fn ct_is_err(&self) -> bool

๐Ÿ‘ŽDeprecated:

ct_is_err branches on the Result variant; use Result::is_err and do not treat the variant as secret

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,

๐Ÿ‘ŽDeprecated:

ct_map invokes only the selected closure; use Result::map_or_else and do not treat the variant as secret

Implementorsยง