Struct MemoryBackend

Source
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.

The block-size is set to 512 bytes.

Source

pub fn new_with_bsize(bsize: u32) -> MemoryBackend

Creates a new instance of the MemoryBackend type with the given block-size.

Source

pub fn block_size(&self) -> u32

Returns the block size specified for this backend instance.

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 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

Source§

type Settings = Settings

Runtime configuration used by the backend. Read more
Source§

type Err = Error

The error type used by methods of this trait.
Source§

type Id = Id

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

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, buf: &[u8]) -> 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§

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

Puts the given buf into the header of the backend. Read more
Source§

fn delete(self)

Deletes the entire instance and all traces. Read more
Source§

impl Create<MemoryBackend> for MemoryBackend

Source§

fn settings(&self) -> Settings

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

fn build( self, header: [u8; 512], _overwrite: bool, ) -> 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 Default for MemoryBackend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MemoryBackend

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Open<MemoryBackend> for MemoryBackend

Source§

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

Create an instance of the Backend. Read more
Source§

impl PartialEq for MemoryBackend

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ReceiveHeader<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 Serialize for MemoryBackend

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MemoryBackend

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,