[][src]Trait lib3h_crypto_api::Buffer

pub trait Buffer: Send + Debug + Deref<Target = [u8]> + DerefMut<Target = [u8]> {
    fn box_clone(&self) -> Box<dyn Buffer>;
fn as_buffer(&self) -> &dyn Buffer;
fn as_buffer_mut(&mut self) -> &mut dyn Buffer;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn set_no_access(&self);
fn set_readable(&self);
fn set_writable(&self); fn read_lock(&self) -> ReadLocker { ... }
fn write_lock(&mut self) -> WriteLocker { ... }
fn zero(&mut self) { ... }
fn write(&mut self, offset: usize, data: &[u8]) -> CryptoResult<()> { ... } }

The Buffer trait is used by crypto_api functions to exchange data. It is implemented for Vec for direct use. For private keys, prefer the type returned by CryptoSystem::buf_new_secure

Required methods

fn box_clone(&self) -> Box<dyn Buffer>

Buffer is designed to be used as a trait-object Since we can't get a sized clone, provide clone in a Box.

fn as_buffer(&self) -> &dyn Buffer

helps work around some sizing issues with rust trait-objects

fn as_buffer_mut(&mut self) -> &mut dyn Buffer

helps work around some sizing issues with rust trait-objects

fn len(&self) -> usize

get the length of the buffer

fn is_empty(&self) -> bool

is this a zero-length buffer?

fn set_no_access(&self)

mark this buffer as no-access memory protection (note, this is a no-op for Vecs)

fn set_readable(&self)

mark this buffer as read-only memory protection (note, this is a no-op for Vecs)

fn set_writable(&self)

mark this buffer as read-write memory protection (note, this is a no-op for Vecs)

Loading content...

Provided methods

fn read_lock(&self) -> ReadLocker

return a locker object that marks this Buffer readable until the locker goes out of scope

fn write_lock(&mut self) -> WriteLocker

return a locker object that marks this Buffer writable until the locker goes out of scope

fn zero(&mut self)

fill the buffer with zeroes

fn write(&mut self, offset: usize, data: &[u8]) -> CryptoResult<()>

write data into this buffer at given offset this function will return CryptoError::WriteOverflow if data is too long

Loading content...

Implementations on Foreign Types

impl Buffer for Vec<u8>[src]

Loading content...

Implementors

Loading content...