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 PartialOrd for Buffer
impl PartialOrd for Buffer
impl StructuralPartialEq for Buffer
Auto Trait Implementations§
impl Freeze for Buffer
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