Struct nuts_memory::MemoryBackend 
source · pub struct MemoryBackend { /* private fields */ }Implementations§
source§impl MemoryBackend
 
impl MemoryBackend
sourcepub fn new() -> MemoryBackend
 
pub fn new() -> MemoryBackend
Creates a new instance of the MemoryBackend type.
The block-size is set to 512 bytes.
sourcepub fn new_with_bsize(bsize: u32) -> MemoryBackend
 
pub fn new_with_bsize(bsize: u32) -> MemoryBackend
Creates a new instance of the MemoryBackend type with the given
block-size.
sourcepub fn block_size(&self) -> u32
 
pub fn block_size(&self) -> u32
Returns the block size specified for this backend instance.
sourcepub fn get(&self, id: &Id) -> Option<&[u8]>
 
pub fn get(&self, id: &Id) -> Option<&[u8]>
Receives the content of the block with the given id.
Returns None if the block does not exist.
sourcepub fn insert(&mut self) -> Result<Id, Error>
 
pub fn insert(&mut self) -> Result<Id, Error>
Inserts a new block.
The block contains only zeros.
Returns the id of the new block.
sourcepub fn insert_data(&mut self, data: &[u8]) -> Result<Id, Error>
 
pub fn insert_data(&mut self, data: &[u8]) -> Result<Id, Error>
Inserts a new block with some initial data.
Assigns the first block-size bytes from data to
the new block. If data does not have block-size
bytes, the new block is padded with zero bytes.
Returns the id of the new block.
Trait Implementations§
source§impl Backend for MemoryBackend
 
impl Backend for MemoryBackend
§type Id = Id
 
type Id = Id
The id identifies a block in the storage. It is used everywhere you
need a pointer to a block.
source§fn block_size(&self) -> u32
 
fn block_size(&self) -> u32
Returns the block size of the backend.
source§fn aquire(&mut self, buf: &[u8]) -> Result<Id, Error>
 
fn aquire(&mut self, buf: &[u8]) -> Result<Id, Error>
Aquires a new block in the backend. Read more
source§fn read(&mut self, id: &Id, buf: &mut [u8]) -> Result<usize, Error>
 
fn read(&mut self, id: &Id, buf: &mut [u8]) -> Result<usize, Error>
Reads a block from the backend. Read more
source§fn write(&mut self, id: &Id, buf: &[u8]) -> Result<usize, Error>
 
fn write(&mut self, id: &Id, buf: &[u8]) -> Result<usize, Error>
Writes a block into the backend. Read more
source§impl Create<MemoryBackend> for MemoryBackend
 
impl Create<MemoryBackend> for MemoryBackend
source§impl Debug for MemoryBackend
 
impl Debug for MemoryBackend
source§impl Default for MemoryBackend
 
impl Default for MemoryBackend
source§impl Open<MemoryBackend> for MemoryBackend
 
impl Open<MemoryBackend> for MemoryBackend
source§impl PartialEq for MemoryBackend
 
impl PartialEq for MemoryBackend
source§fn eq(&self, other: &MemoryBackend) -> bool
 
fn eq(&self, other: &MemoryBackend) -> bool
This method tests for 
self and other values to be equal, and is used
by ==.source§impl ReceiveHeader<MemoryBackend> for MemoryBackend
 
impl ReceiveHeader<MemoryBackend> for MemoryBackend
impl StructuralPartialEq for MemoryBackend
Auto Trait Implementations§
impl Freeze for MemoryBackend
impl RefUnwindSafe for MemoryBackend
impl Send for MemoryBackend
impl Sync for MemoryBackend
impl Unpin for MemoryBackend
impl UnwindSafe for MemoryBackend
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