pub struct MemoryBackend { /* private fields */ }
Expand description

The Backend implementation itself.

See the module documentation for details.

Implementations§

source§

impl MemoryBackend

source

pub fn new() -> MemoryBackend

Creates a new instance of the MemoryBackend type.

source

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.

source

pub fn insert(&mut self) -> Result<Id, Error>

Inserts a new block.

The block contains only zeros.

Returns the id of the new block.

source

pub fn insert_data(&mut self, data: &[u8]) -> Result<Id, Error>

Inserts a new block with some initial data.

Assigns the first 512 bytes from data to the new block. If data does not have 512 bytes, the new block is padded with zero bytes.

Returns the id of the new block.

Trait Implementations§

source§

impl Backend for MemoryBackend

§

type CreateOptions = MemoryBackend

Options used to create a backend instance. Read more
§

type OpenOptions = MemoryBackend

Options used to open a backend instance. Read more
§

type Settings = ()

Runtime configuration used by the backend. Read more
§

type Err = Error

The error type used by methods of this trait.
§

type Id = Id

The id identifies a block in the storage. It is used everywhere you need a pointer to a block.
§

type Info = ()

Information of the backend. Read more
source§

fn info(&self) -> Result<(), Error>

Returns information from the backend. Read more
source§

fn block_size(&self) -> u32

Returns the block size of the backend.
source§

fn aquire(&mut self) -> Result<Id, Error>

Aquires a new block in the backend. Read more
source§

fn release(&mut self, id: Id) -> Result<(), Error>

Releases a block again. Read more
source§

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>

Writes a block into the backend. Read more
source§

impl Create<MemoryBackend> for MemoryBackend

source§

fn settings(&self)

Returns the settings of this backend instance. Read more
source§

fn build(self) -> Result<MemoryBackend, Error>

Create an instance of the Backend. Read more
source§

impl Debug for MemoryBackend

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl HeaderGet<MemoryBackend> for MemoryBackend

source§

fn get_header_bytes(&mut self, bytes: &mut [u8; 512]) -> Result<(), Error>

Receives the binary header data from the backend. Read more
source§

impl HeaderSet<MemoryBackend> for MemoryBackend

source§

fn put_header_bytes(&mut self, bytes: &[u8; 512]) -> Result<(), Error>

Puts the given bytes into the header of the backend. Read more
source§

impl Open<MemoryBackend> for MemoryBackend

source§

fn build(self, _settings: ()) -> Result<MemoryBackend, Error>

Create an instance of the Backend. Read more
source§

impl PartialEq for MemoryBackend

source§

fn eq(&self, other: &MemoryBackend) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for MemoryBackend

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.