[−][src]Struct cryptovec::CryptoVec
A buffer which zeroes its memory on .clear()
, .resize()
and
reallocations, to avoid copying secrets around.
Implementations
impl CryptoVec
[src]
pub fn new() -> CryptoVecⓘ
[src]
Creates a new CryptoVec
.
pub fn new_zeroed(size: usize) -> CryptoVecⓘ
[src]
Creates a new CryptoVec
with n
zeros.
pub fn with_capacity(capacity: usize) -> CryptoVecⓘ
[src]
Creates a new CryptoVec
with capacity capacity
.
pub fn len(&self) -> usize
[src]
Length of this CryptoVec
.
assert_eq!(cryptovec::CryptoVec::new().len(), 0)
pub fn is_empty(&self) -> bool
[src]
Returns true
if and only if this CryptoVec is empty.
assert!(cryptovec::CryptoVec::new().is_empty())
pub fn resize(&mut self, size: usize)
[src]
Resize this CryptoVec, appending zeros at the end. This may perform at most one reallocation, overwriting the previous version with zeros.
pub fn clear(&mut self)
[src]
Clear this CryptoVec (retaining the memory).
let mut v = cryptovec::CryptoVec::new(); v.extend(b"blabla"); v.clear(); assert!(v.is_empty())
pub fn push(&mut self, s: u8)
[src]
Append a new byte at the end of this CryptoVec.
pub fn push_u32_be(&mut self, s: u32)
[src]
Append a new u32, big endian-encoded, at the end of this CryptoVec.
let mut v = cryptovec::CryptoVec::new(); let n = 43554; v.push_u32_be(n); assert_eq!(n, v.read_u32_be(0))
pub fn read_u32_be(&self, i: usize) -> u32
[src]
Read a big endian-encoded u32 from this CryptoVec, with the
first byte at position i
.
let mut v = cryptovec::CryptoVec::new(); let n = 99485710; v.push_u32_be(n); assert_eq!(n, v.read_u32_be(0))
pub fn read<R: Read>(&mut self, n_bytes: usize, r: R) -> Result<usize, Error>
[src]
Read n_bytes
from r
, and append them at the end of this
CryptoVec
. Returns the number of bytes read (and appended).
pub fn write_all_from<W: Write>(
&self,
offset: usize,
w: W
) -> Result<usize, Error>
[src]
&self,
offset: usize,
w: W
) -> Result<usize, Error>
Write all this CryptoVec to the provided Write
. Returns the
number of bytes actually written.
let mut v = cryptovec::CryptoVec::new(); v.extend(b"blabla"); let mut s = std::io::stdout(); v.write_all_from(0, &mut s).unwrap();
pub fn resize_mut(&mut self, n: usize) -> &mut [u8]
[src]
Resize this CryptoVec, returning a mutable borrow to the extra bytes.
let mut v = cryptovec::CryptoVec::new(); v.resize_mut(4).clone_from_slice(b"test");
pub fn extend(&mut self, s: &[u8])
[src]
Append a slice at the end of this CryptoVec.
let mut v = cryptovec::CryptoVec::new(); v.extend(b"test");
pub fn from_slice(s: &[u8]) -> CryptoVecⓘ
[src]
Create a CryptoVec
from a slice
CryptoVec::from_slice(b"test");
Trait Implementations
impl AsMut<[u8]> for CryptoVec
[src]
impl AsRef<[u8]> for CryptoVec
[src]
impl Clone for CryptoVec
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for CryptoVec
[src]
impl Default for CryptoVec
[src]
impl Deref for CryptoVec
[src]
impl DerefMut for CryptoVec
[src]
impl Drop for CryptoVec
[src]
impl From<String> for CryptoVec
[src]
impl From<Vec<u8>> for CryptoVec
[src]
impl Index<Range<usize>> for CryptoVec
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: Range<usize>) -> &[u8]
[src]
impl Index<RangeFrom<usize>> for CryptoVec
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: RangeFrom<usize>) -> &[u8]
[src]
impl Index<RangeFull> for CryptoVec
[src]
impl Index<RangeTo<usize>> for CryptoVec
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: RangeTo<usize>) -> &[u8]
[src]
impl Index<usize> for CryptoVec
[src]
impl IndexMut<Range<usize>> for CryptoVec
[src]
impl IndexMut<RangeFrom<usize>> for CryptoVec
[src]
impl IndexMut<RangeFull> for CryptoVec
[src]
impl IndexMut<RangeTo<usize>> for CryptoVec
[src]
impl Send for CryptoVec
[src]
impl Sync for CryptoVec
[src]
impl Unpin for CryptoVec
[src]
impl Write for CryptoVec
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
[src]
fn flush(&mut self) -> Result<(), Error>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
fn is_write_vectored(&self) -> bool
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
[src]
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for CryptoVec
impl UnwindSafe for CryptoVec
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>,