pub struct TimingProtection {
pub enabled: bool,
pub target_duration_ns: u64,
}Expand description
Constant-time wrapper configuration.
Fields§
§enabled: boolEnable constant-time wrapping.
target_duration_ns: u64Target minimum duration for the protected call, in nanoseconds when
a wall-clock source is available (native std, or wasm32 with the
wasm feature and global.performance).
On platforms that use the tick counter fallback (see module docs), this value is measured in counter ticks, not literal nanoseconds.
Implementations§
Source§impl TimingProtection
impl TimingProtection
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Disabled — zero overhead, no constant-time guarantee.
Sourcepub fn protect<F, R>(&self, func: F) -> Rwhere
F: FnOnce() -> R,
pub fn protect<F, R>(&self, func: F) -> Rwhere
F: FnOnce() -> R,
Run func and busy-wait until target_duration_ns
has elapsed from the start of the call.
Sourcepub async fn protect_async<F, Fut, R>(&self, func: F) -> R
pub async fn protect_async<F, Fut, R>(&self, func: F) -> R
Async variant of protect.
Sourcepub fn protect_with_timing<F, R>(&self, func: F) -> (R, u64)where
F: FnOnce() -> R,
pub fn protect_with_timing<F, R>(&self, func: F) -> (R, u64)where
F: FnOnce() -> R,
Run func with constant-time protection and return (result, elapsed).
When a wall clock is available (native std, or wasm32 + wasm), the
second value is elapsed time in nanoseconds including the busy-wait. On
tick-counter-only targets (see module docs), the delta is in counter
ticks, not literal nanoseconds. When the wrapper is disabled, the
delta reflects only the operation’s natural duration in the same units.
Sourcepub async fn protect_with_timing_async<F, Fut, R>(&self, func: F) -> (R, u64)
pub async fn protect_with_timing_async<F, Fut, R>(&self, func: F) -> (R, u64)
Async variant of protect_with_timing.
See protect_with_timing for semantics of
the elapsed value.
Trait Implementations§
Source§impl Clone for TimingProtection
impl Clone for TimingProtection
Source§fn clone(&self) -> TimingProtection
fn clone(&self) -> TimingProtection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TimingProtection
impl Debug for TimingProtection
Source§impl Default for TimingProtection
impl Default for TimingProtection
Source§impl PartialEq for TimingProtection
impl PartialEq for TimingProtection
Source§fn eq(&self, other: &TimingProtection) -> bool
fn eq(&self, other: &TimingProtection) -> bool
self and other values to be equal, and is used by ==.