[−][src]Struct arx_kw::Choice
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
impl Choice[src]
pub fn unwrap_u8(&self) -> u8[src]
Unwrap the Choice wrapper to reveal the underlying u8.
Note
This function only exists as an escape hatch for the rare case
where it's not possible to use one of the subtle-provided
trait impls.
To convert a Choice to a bool, use the From implementation instead.
Trait Implementations
impl BitAnd<Choice> for Choice[src]
type Output = Choice
The resulting type after applying the & operator.
pub fn bitand(self, rhs: Choice) -> Choice[src]
impl BitAndAssign<Choice> for Choice[src]
pub fn bitand_assign(&mut self, rhs: Choice)[src]
impl BitOr<Choice> for Choice[src]
type Output = Choice
The resulting type after applying the | operator.
pub fn bitor(self, rhs: Choice) -> Choice[src]
impl BitOrAssign<Choice> for Choice[src]
pub fn bitor_assign(&mut self, rhs: Choice)[src]
impl BitXor<Choice> for Choice[src]
type Output = Choice
The resulting type after applying the ^ operator.
pub fn bitxor(self, rhs: Choice) -> Choice[src]
impl BitXorAssign<Choice> for Choice[src]
pub fn bitxor_assign(&mut self, rhs: Choice)[src]
impl Clone for Choice[src]
impl ConditionallySelectable for Choice[src]
pub fn conditional_select(a: &Choice, b: &Choice, choice: Choice) -> Choice[src]
pub fn conditional_assign(&mut self, other: &Self, choice: Choice)[src]
pub fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)[src]
impl ConstantTimeEq for Choice[src]
impl Copy for Choice[src]
impl Debug for Choice[src]
impl From<u8> for Choice[src]
impl Not for Choice[src]
Auto Trait Implementations
impl RefUnwindSafe for Choice[src]
impl Send for Choice[src]
impl Sync for Choice[src]
impl Unpin for Choice[src]
impl UnwindSafe for Choice[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,