[−][src]Trait lib3h_crypto_api::Buffer
The Buffer trait is used by crypto_api functions to exchange data.
It is implemented for Vec
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 Vec
fn set_readable(&self)
mark this buffer as read-only memory protection
(note, this is a no-op for Vec
fn set_writable(&self)
mark this buffer as read-write memory protection
(note, this is a no-op for Vec
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
fn compare(&self, b: &Box<dyn Buffer>) -> i32
compare this buffer to another buffer Return : | if a > b; return 1 | if a < b; return -1 | if a == b; return 0