Struct win_crypto_ng::buffer::Buffer
source · pub struct Buffer { /* private fields */ }
Expand description
Secure buffer implementation.
On creation, the buffer is initialized with zeroes.
On destruction, if the zeroize
feature is enabled, its content is set to
0
before being released.
Implementations§
source§impl Buffer
impl Buffer
sourcepub fn new(size: usize) -> Self
pub fn new(size: usize) -> Self
Create a new buffer of the specified size.
Examples
let buf = Buffer::new(76);
assert_eq!(buf.len(), 76);
sourcepub fn from(data: &[u8]) -> Self
pub fn from(data: &[u8]) -> Self
Create a new buffer with its data copied from the slice.
Examples
const SOME_DATA: &'static [u8] = &[0x01, 0x02, 0x03, 0x04];
let buf = Buffer::from(SOME_DATA);
assert_eq!(buf.as_slice(), SOME_DATA);
pub fn from_vec(data: Vec<u8>) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_ptr(&self) -> *const u8
pub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn into_inner(self) -> Vec<u8>
Trait Implementations§
source§impl PartialEq<Buffer> for Buffer
impl PartialEq<Buffer> for Buffer
source§impl PartialOrd<Buffer> for Buffer
impl PartialOrd<Buffer> for Buffer
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl StructuralPartialEq for Buffer
Auto Trait Implementations§
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
Blanket Implementations§
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