pub struct WriteBatch { /* private fields */ }
Expand description
An atomic batch of write operations.
Making an atomic commit of several writes:
use ckb_rocksdb::{prelude::*, WriteBatch};
let path = "_path_for_rocksdb_storage1";
let db = DB::open_default(&path).unwrap();
let mut batch = WriteBatch::default();
batch.put(b"my key", b"my value");
batch.put(b"key2", b"value2");
batch.put(b"key3", b"value3");
db.write(&batch); // Atomically commits the batch
Implementations§
Source§impl WriteBatch
impl WriteBatch
pub fn len(&self) -> usize
Sourcepub fn size_in_bytes(&self) -> usize
pub fn size_in_bytes(&self) -> usize
Return WriteBatch serialized size (in bytes).
pub fn is_empty(&self) -> bool
Sourcepub fn put<K, V>(&mut self, key: K, value: V) -> Result<(), Error>
pub fn put<K, V>(&mut self, key: K, value: V) -> Result<(), Error>
Insert a value into the database under the given key.
pub fn put_cf<K, V>( &mut self, cf: &ColumnFamily, key: K, value: V, ) -> Result<(), Error>
pub fn merge<K, V>(&mut self, key: K, value: V) -> Result<(), Error>
pub fn merge_cf<K, V>( &mut self, cf: &ColumnFamily, key: K, value: V, ) -> Result<(), Error>
Sourcepub fn delete<K>(&mut self, key: K) -> Result<(), Error>
pub fn delete<K>(&mut self, key: K) -> Result<(), Error>
Remove the database entry for key.
Returns an error if the key was not found.
pub fn delete_cf<K>(&mut self, cf: &ColumnFamily, key: K) -> Result<(), Error>
Sourcepub fn delete_range<K>(&mut self, from: K, to: K) -> Result<(), Error>
pub fn delete_range<K>(&mut self, from: K, to: K) -> Result<(), Error>
Remove database entries from start key to end key.
Removes the database entries in the range [“begin_key”, “end_key”), i.e., including “begin_key” and excluding “end_key”. It is not an error if no keys exist in the range [“begin_key”, “end_key”).
Sourcepub fn delete_range_cf<K>(
&mut self,
cf: &ColumnFamily,
from: K,
to: K,
) -> Result<(), Error>
pub fn delete_range_cf<K>( &mut self, cf: &ColumnFamily, from: K, to: K, ) -> Result<(), Error>
Remove database entries in column family from start key to end key.
Removes the database entries in the range [“begin_key”, “end_key”), i.e., including “begin_key” and excluding “end_key”. It is not an error if no keys exist in the range [“begin_key”, “end_key”).
Trait Implementations§
Source§impl Default for WriteBatch
impl Default for WriteBatch
Source§fn default() -> WriteBatch
fn default() -> WriteBatch
Source§impl Drop for WriteBatch
impl Drop for WriteBatch
Source§impl Handle<rocksdb_writebatch_t> for WriteBatch
impl Handle<rocksdb_writebatch_t> for WriteBatch
fn handle(&self) -> *mut rocksdb_writebatch_t
Auto Trait Implementations§
impl Freeze for WriteBatch
impl RefUnwindSafe for WriteBatch
impl !Send for WriteBatch
impl !Sync for WriteBatch
impl Unpin for WriteBatch
impl UnwindSafe for WriteBatch
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
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