ekv

Crates

git

Versions

default

Flavors

Struct ekv::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>,

§

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

§

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.