pub struct Usage<T, Scope = DefaultScope>(/* private fields */);Implementations§
Source§impl<T, S> Usage<T, S>
impl<T, S> Usage<T, S>
pub fn new(x: <Usage<T, S> as Controlled>::Inner) -> Selfwhere
Self: Controlled,
S: Scope,
Trait Implementations§
Source§impl<T, Scope> Controlled for Usage<T, Scope>where
T: Controlled,
impl<T, Scope> Controlled for Usage<T, Scope>where
T: Controlled,
type Inner = <T as Controlled>::Inner
Source§fn risky_unwrap(self) -> Self::Inner
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
fn init_from_inner(x: Self::Inner) -> Self
Source§fn risky_ref(&self) -> &Self::Inner
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!
fn inner_mut(&mut self) -> &mut Self::Inner
Source§fn new(inner: Self::Inner) -> Selfwhere
Self: Sized,
fn new(inner: Self::Inner) -> Selfwhere
Self: Sized,
Initialize a new instance of the Controlled type from the inner value.
Source§fn generate<F>(f: F) -> Self
fn generate<F>(f: F) -> Self
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>
fn generate_ok<F, E>(f: F) -> Result<Self, E>
Generate a new Controlled type from a function that returns a
Result with the inner value. Read moreSource§fn map<B, F>(self, f: F) -> <Self as ReplaceT<B>>::Outputwhere
Self: Sized + ReplaceT<B>,
F: FnOnce(<Self as Controlled>::Inner) -> B,
<Self as ReplaceT<B>>::Output: Controlled<Inner = B>,
B: Zeroize,
fn map<B, F>(self, f: F) -> <Self as ReplaceT<B>>::Outputwhere
Self: Sized + ReplaceT<B>,
F: FnOnce(<Self as Controlled>::Inner) -> B,
<Self as ReplaceT<B>>::Output: Controlled<Inner = B>,
B: Zeroize,
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,
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 moreSource§fn zip<Other, Out, F>(self, b: Other, f: F) -> Protected<Out>
fn zip<Other, Out, F>(self, b: Other, f: F) -> Protected<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
fn zip_ref<'a, A, Other, Out, F>( self, other: &'a Other, f: F, ) -> <Self as ReplaceT<Out>>::Output
Like
zip but the second argument is a reference. Read moreSource§fn update<F>(&mut self, f: F)
fn update<F>(&mut self, f: F)
Similar to
map but using references to that the inner value is updated in place. Read moreSource§fn update_with<Other, F>(&mut self, other: Other, f: F)
fn update_with<Other, F>(&mut self, other: Other, f: F)
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)
fn update_with_ref<'a, A, F>(&mut self, other: ProtectedRef<'a, A>, f: F)
Like
update_with but the second argument is a reference. Read moreSource§fn iter<'a, I>(&'a self) -> impl Iterator<Item = Protected<I>>
fn iter<'a, I>(&'a self) -> impl Iterator<Item = Protected<I>>
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) -> Selfwhere
Self: Sized,
fn replace(&mut self, new: Self) -> Selfwhere
Self: Sized,
Replace the inner value with a new one.
The new value must be
Self. Read moreSource§fn risky_inner_mut(&mut self) -> &mut Self::Inner
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, A> Serialize for Usage<T, A>
Serialize implementation for Usage if it is controlled and the inner type is safe serializable.
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.
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>
impl<T, Scope> Sync for Usage<T, Scope>
impl<T, Scope> Unpin for Usage<T, Scope>
impl<T, Scope> UnwindSafe for Usage<T, Scope>where
T: UnwindSafe,
Scope: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T> AsProtectedRef<'a, <T as Controlled>::Inner> for Twhere
T: Controlled,
impl<'a, T> AsProtectedRef<'a, <T as Controlled>::Inner> for Twhere
T: Controlled,
fn as_protected_ref(&'a self) -> ProtectedRef<'a, <T as Controlled>::Inner>
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