Struct s2n_quic_core::ct::Choice
source · pub struct Choice(/* private fields */);
Expand description
The Choice
struct represents a choice for use in conditional assignment.
It is a wrapper around a u8
, which should have the value either 1
(true)
or 0
(false).
The conversion from u8
to Choice
passes the value through an optimization
barrier, as a best-effort attempt to prevent the compiler from inferring that
the Choice
value is a boolean. This strategy is based on Tim Maclean’s
work on rust-timing-shield
, which attempts to provide
a more comprehensive approach for preventing software side-channels in Rust
code.
The Choice
struct implements operators for AND, OR, XOR, and NOT, to allow
combining Choice
values. These operations do not short-circuit.
Implementations§
Trait Implementations§
source§impl BitAndAssign for Choice
impl BitAndAssign for Choice
source§fn bitand_assign(&mut self, rhs: Choice)
fn bitand_assign(&mut self, rhs: Choice)
Performs the
&=
operation. Read moresource§impl BitOrAssign for Choice
impl BitOrAssign for Choice
source§fn bitor_assign(&mut self, rhs: Choice)
fn bitor_assign(&mut self, rhs: Choice)
Performs the
|=
operation. Read moresource§impl BitXorAssign for Choice
impl BitXorAssign for Choice
source§fn bitxor_assign(&mut self, rhs: Choice)
fn bitxor_assign(&mut self, rhs: Choice)
Performs the
^=
operation. Read moresource§impl ConditionallySelectable for Choice
impl ConditionallySelectable for Choice
source§impl ConstantTimeEq for Choice
impl ConstantTimeEq for Choice
impl Copy for Choice
Auto Trait Implementations§
impl Freeze for Choice
impl RefUnwindSafe for Choice
impl Send for Choice
impl Sync for Choice
impl Unpin for Choice
impl UnwindSafe for Choice
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more