pub struct Batch { /* private fields */ }Available on crate feature
std only.Expand description
An ordered group of writes applied together.
Operations are recorded in call order and replayed in that order when the batch is written, so a later operation on a key overrides an earlier one.
§Examples
use lsm_db::Batch;
let mut batch = Batch::new();
batch.put(b"alpha", b"1");
batch.put(b"beta", b"2");
batch.delete(b"gamma");
assert_eq!(batch.len(), 3);Implementations§
Source§impl Batch
impl Batch
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty batch.
§Examples
use lsm_db::Batch;
let batch = Batch::new();
assert!(batch.is_empty());Sourcepub fn put(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>)
pub fn put(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>)
Queue setting key to value.
Both are copied into the batch, so the caller’s buffers are free to be reused immediately.
§Examples
use lsm_db::Batch;
let mut batch = Batch::new();
batch.put(b"key", b"value");
assert_eq!(batch.len(), 1);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Batch
impl RefUnwindSafe for Batch
impl Send for Batch
impl Sync for Batch
impl Unpin for Batch
impl UnsafeUnpin for Batch
impl UnwindSafe for Batch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more