Struct runtime::GuardedVec [−][src]
pub struct GuardedVec<T: Bytes> { /* fields omitted */ }
A guarded type for protecting variable-length secrets allocated on the heap.
Provides the following features and guarantees:
- Causes segfault upon access without using a borrow.
- Protected using mprotect:
Prot::NoAccess
- when the box has no current borrows.Prot::ReadOnly
- when the box has at least one current immutable borrow.Prot::ReadWrite
- when the box has a current mutable borrow (can only have one at a time).
- The allocated memory uses guard pages both proceeding and following the memory. Overflows and large underflows cause immediate termination of the program.
- A canary proceeds the memory location to detect smaller underflows. The program will drop the underlying memory and terminate if detected.
- The Memory is locked with
mlock
. - When the memory is freed,
munlock
is called. - The memory is zeroed when no longer in use via
sodium_free
. Guarded
types can be compared in constant time.Guarded
types can not be printed usingDebug
.- The interior data of a
Guarded
type may not beClone
.GuardedVec
includes serialization which converts the data into a vector before its serialized by serde. Upon deserialization, the data is returned back to a new GuardedVec.
Implementations
impl<T: Bytes> GuardedVec<T>
[src]
pub fn new<F>(len: usize, f: F) -> Self where
F: FnOnce(&mut [T]),
[src]
F: FnOnce(&mut [T]),
pub fn try_new<U, E, F>(f: F) -> Result<Self, E> where
F: FnOnce(&mut [T]) -> Result<U, E>,
[src]
F: FnOnce(&mut [T]) -> Result<U, E>,
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn size(&self) -> usize
[src]
pub fn borrow(&self) -> Ref<'_, T>
[src]
pub fn borrow_mut(&mut self) -> RefMut<'_, T>
[src]
impl<T: Bytes + Randomized> GuardedVec<T>
[src]
impl<T: Bytes + Zeroed> GuardedVec<T>
[src]
Trait Implementations
impl<T: Clone + Bytes> Clone for GuardedVec<T>
[src]
fn clone(&self) -> GuardedVec<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Bytes> Debug for GuardedVec<T>
[src]
impl<'de, T: Bytes> Deserialize<'de> for GuardedVec<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl<T: Eq + Bytes> Eq for GuardedVec<T>
[src]
impl<T: Bytes + Zeroed> From<&'_ mut [T]> for GuardedVec<T>
[src]
impl<T: Bytes + ConstEq> PartialEq<GuardedVec<T>> for GuardedVec<T>
[src]
impl<T: Bytes + Send> Send for GuardedVec<T>
[src]
impl<T: Bytes> Serialize for GuardedVec<T> where
T: Serialize,
[src]
T: Serialize,
impl<T: Bytes> StructuralEq for GuardedVec<T>
[src]
impl<T: Bytes + Sync> Sync for GuardedVec<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for GuardedVec<T>
impl<T> Unpin for GuardedVec<T>
impl<T> UnwindSafe for GuardedVec<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
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> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
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>,