Usage

Struct Usage 

Source
pub struct Usage<T, Scope = DefaultScope>(/* private fields */);

Implementations§

Source§

impl<T, S> Usage<T, S>

Source

pub fn new(x: <Usage<T, S> as Controlled>::Inner) -> Self
where Self: Controlled, S: Scope,

Trait Implementations§

Source§

impl<T, Scope> Controlled for Usage<T, Scope>
where T: Controlled,

Source§

type Inner = <T as Controlled>::Inner

Source§

fn risky_unwrap(self) -> Self::Inner

Unwraps the inner value of the Controlled type. This is a risky operation because it consumes the Controlled type and returns the inner value negating the protections that the Controlled type provides. Read more
Source§

fn init_from_inner(x: Self::Inner) -> Self

Source§

fn risky_ref(&self) -> &Self::Inner

Provides a reference to the inner value. This is a risky operation because it bypasses the protections that the Controlled type provides. Use with caution!
Source§

fn inner_mut(&mut self) -> &mut Self::Inner

Source§

fn new(inner: Self::Inner) -> Self
where Self: Sized,

Initialize a new instance of the Controlled type from the inner value.
Source§

fn generate<F>(f: F) -> Self
where Self: Sized, F: FnOnce() -> Self::Inner,

Generate a new instance of the Controlled type from a function that returns the inner value. Read more
Source§

fn generate_ok<F, E>(f: F) -> Result<Self, E>
where Self: Sized, F: FnOnce() -> Result<Self::Inner, E>,

Generate a new Controlled type from a function that returns a Result with the inner value. Read more
Source§

fn map<B, F>(self, f: F) -> <Self as ReplaceT<B>>::Output
where Self: Sized + ReplaceT<B>, F: FnOnce(<Self as Controlled>::Inner) -> B, <Self as ReplaceT<B>>::Output: Controlled<Inner = B>, B: Zeroize,

Map the inner value of this Controlled type. Conceptually similar to Option::map`. Read more
Source§

fn map_ok<B, F, E>(self, f: F) -> Result<<Self as ReplaceT<B>>::Output, E>
where Self: Sized + ReplaceT<B>, F: FnOnce(<Self as Controlled>::Inner) -> Result<B, E>, <Self as ReplaceT<B>>::Output: Controlled<Inner = B>, B: Zeroize,

Similar to map but the closure returns a Result with the new inner value. The result is a Result with the new Controlled type. Read more
Source§

fn zip<Other, Out, F>(self, b: Other, f: F) -> Protected<Out>
where Self: Sized, Other: Controlled, Out: Zeroize, F: FnOnce(Self::Inner, Other::Inner) -> Out,

Zip two Controlled values of the same type together with a function that combines them. Read more
Source§

fn zip_ref<'a, A, Other, Out, F>( self, other: &'a Other, f: F, ) -> <Self as ReplaceT<Out>>::Output
where A: ?Sized + 'a, Self: Sized + ReplaceT<Out>, <Self as ReplaceT<Out>>::Output: Controlled<Inner = Out>, Other: AsProtectedRef<'a, A>, Out: Zeroize, F: FnOnce(Self::Inner, &A) -> Out,

Like zip but the second argument is a reference. Read more
Source§

fn update<F>(&mut self, f: F)
where F: FnMut(&mut Self::Inner),

Similar to map but using references to that the inner value is updated in place. Read more
Source§

fn update_with<Other, F>(&mut self, other: Other, f: F)
where F: FnMut(&mut Self::Inner, Other::Inner), Other: Controlled,

Update the inner value with another Controlled value. The inner value of the second argument is passed to the closure. Read more
Source§

fn update_with_ref<'a, A, F>(&mut self, other: ProtectedRef<'a, A>, f: F)
where A: ?Sized + 'a, F: FnMut(&mut Self::Inner, &A),

Like update_with but the second argument is a reference. Read more
Source§

fn iter<'a, I>(&'a self) -> impl Iterator<Item = Protected<I>>
where <Self as Controlled>::Inner: AsRef<[I]>, I: Copy + 'a,

Iterate over the inner value and wrap each element in a Protected. I must be Copy because Protected always takes ownership of the inner value.
Source§

fn replace(&mut self, new: Self) -> Self
where Self: Sized,

Replace the inner value with a new one. The new value must be Self. Read more
Source§

fn risky_inner_mut(&mut self) -> &mut Self::Inner

Provides a mutable reference to the inner value. This is a risky operation because it bypasses the protections that the Controlled type provides. Use with caution!
Source§

impl<T, K, S> ReplaceT<K> for Usage<Protected<T>, S>

Source§

impl<T, A> Serialize for Usage<T, A>

Serialize implementation for Usage if it is controlled and the inner type is safe serializable.

For example, this allows us to serialize a Usage<Exportable<Protected<[u8; 32]>>> type.

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T, S> Zeroed for Usage<T, S>
where T: Zeroed,

Source§

fn zeroed() -> Self

Source§

impl<T, S> Acceptable<S> for Usage<T, S>
where S: Scope,

Auto Trait Implementations§

§

impl<T, Scope> Freeze for Usage<T, Scope>
where T: Freeze,

§

impl<T, Scope> RefUnwindSafe for Usage<T, Scope>
where T: RefUnwindSafe, Scope: RefUnwindSafe,

§

impl<T, Scope> Send for Usage<T, Scope>
where T: Send, Scope: Send,

§

impl<T, Scope> Sync for Usage<T, Scope>
where T: Sync, Scope: Sync,

§

impl<T, Scope> Unpin for Usage<T, Scope>
where T: Unpin, Scope: Unpin,

§

impl<T, Scope> UnwindSafe for Usage<T, Scope>
where T: UnwindSafe, Scope: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T> AsProtectedRef<'a, <T as Controlled>::Inner> for T
where T: Controlled,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'de, T> SafeDeserialize<'de> for T
where <T as Controlled>::Inner: SafeDeserialize<'de>, T: Controlled,

Source§

fn safe_deserialize<S>( deserializer: S, ) -> Result<T, <S as Deserializer<'de>>::Error>
where S: Deserializer<'de>,

Source§

impl<T> SafeSerialize for T

Source§

fn safe_serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.