ekv

Crates

git

Versions

default

Flavors

ekv

Struct WriteTransaction

Source
pub struct WriteTransaction<'a, F: Flash + 'a, M: RawMutex + 'a> { /* private fields */ }
Expand description

In-progress write transaction.

§Cancelation

If any operation within the transaction (write or delete) either fails, or is canceled (due to dropping its Future before completion), the entire write transaction is canceled.

When the transaction is canceled, all operations will return TransactionCanceled errors. To recover, you must drop the entire WriteTransaction, and (if desired) open a new one to retry the writes.

Implementations§

Source§

impl<'a, F: Flash + 'a, M: RawMutex + 'a> WriteTransaction<'a, F, M>

Source

pub async fn write( &mut self, key: &[u8], value: &[u8], ) -> Result<(), WriteError<F::Error>>

Write a key to the database.

If the key was already present, the previous value is overwritten.

Source

pub async fn delete(&mut self, key: &[u8]) -> Result<(), WriteError<F::Error>>

Delete a key from the database.

If the key was not present, this is a no-op.

Source

pub async fn commit(self) -> Result<(), CommitError<F::Error>>

Commit the transaction.

This will wait until no read transaction is open. While waiting, opening new read transactions is blocked, to prevent readers from starving writers.

This makes all the writes permanent on the underlyling database. When it returns, the writes are guaranteed to be fully safely written to flash, so they can’t get lost by a crash or a power failure anymore.

Committing is atomic: if commit is interrupted (due to power loss, crash, or canceling the future), it is guaranteed that either all or none of the writes in the transaction are committed.

Trait Implementations§

Source§

impl<'a, F: Flash + 'a, M: RawMutex + 'a> Drop for WriteTransaction<'a, F, M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, F, M> Freeze for WriteTransaction<'a, F, M>

§

impl<'a, F, M> !RefUnwindSafe for WriteTransaction<'a, F, M>

§

impl<'a, F, M> Send for WriteTransaction<'a, F, M>
where M: Sync, F: Send,

§

impl<'a, F, M> Sync for WriteTransaction<'a, F, M>
where M: Sync, F: Send,

§

impl<'a, F, M> Unpin for WriteTransaction<'a, F, M>

§

impl<'a, F, M> !UnwindSafe for WriteTransaction<'a, F, M>

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.