pub struct Batch<'a, K, V, D>{ /* private fields */ }Expand description
A batch of changes which may be written to an underlying database with Batchable::write_batch. Writes and deletes to a batch are not applied to the database until the batch is written but will be reflected in reads from the batch.
Implementations§
Source§impl<'a, K, V, D> Batch<'a, K, V, D>
impl<'a, K, V, D> Batch<'a, K, V, D>
Sourcepub const fn new(db: &'a D) -> Self
pub const fn new(db: &'a D) -> Self
Returns a new batch of changes that may be written to the database.
Sourcepub async fn get(&self, key: &K) -> Result<Option<V>, Error>
pub async fn get(&self, key: &K) -> Result<Option<V>, Error>
Returns the value of key in the batch, or the value in the database if it is not present
in the batch.
Sourcepub async fn create(&mut self, key: K, value: V) -> Result<bool, Error>
pub async fn create(&mut self, key: K, value: V) -> Result<bool, Error>
Creates a new key-value pair in the batch if it isn’t present in the batch or database. Returns true if the key was created, false if it already existed.
Sourcepub async fn update(&mut self, key: K, value: V) -> Result<(), Error>
pub async fn update(&mut self, key: K, value: V) -> Result<(), Error>
Updates the value of key to value in the batch.
Sourcepub async fn delete(&mut self, key: K) -> Result<bool, Error>
pub async fn delete(&mut self, key: K) -> Result<bool, Error>
Deletes key from the batch.
Returns true if the key was in the batch or database, false otherwise.
Sourcepub async fn delete_unchecked(&mut self, key: K) -> Result<(), Error>
pub async fn delete_unchecked(&mut self, key: K) -> Result<(), Error>
Deletes key from the batch without checking if it is present in the batch or database.
Trait Implementations§
Source§impl<'a, K, V, D> IntoIterator for Batch<'a, K, V, D>
impl<'a, K, V, D> IntoIterator for Batch<'a, K, V, D>
Auto Trait Implementations§
impl<'a, K, V, D> Freeze for Batch<'a, K, V, D>
impl<'a, K, V, D> RefUnwindSafe for Batch<'a, K, V, D>
impl<'a, K, V, D> Send for Batch<'a, K, V, D>
impl<'a, K, V, D> Sync for Batch<'a, K, V, D>
impl<'a, K, V, D> Unpin for Batch<'a, K, V, D>
impl<'a, K, V, D> UnwindSafe for Batch<'a, K, V, D>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more