pub struct WriteBatch { /* private fields */ }
Expand description
An atomic batch of write operations.
Making an atomic commit of several writes:
use rocksdb::{DB, WriteBatch};
let db = DB::open_default("path/for/rocksdb/storage1").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
pub fn is_empty(&self) -> bool
Sourcepub fn put(&mut self, key: &[u8], value: &[u8]) -> Result<(), Error>
pub fn put(&mut self, key: &[u8], value: &[u8]) -> Result<(), Error>
Insert a value into the database under the given key.
pub fn put_cf( &mut self, cf: ColumnFamily, key: &[u8], value: &[u8], ) -> Result<(), Error>
pub fn merge(&mut self, key: &[u8], value: &[u8]) -> Result<(), Error>
pub fn merge_cf( &mut self, cf: ColumnFamily, key: &[u8], value: &[u8], ) -> Result<(), Error>
Sourcepub fn delete(&mut self, key: &[u8]) -> Result<(), Error>
pub fn delete(&mut self, key: &[u8]) -> Result<(), Error>
Remove the database entry for key.
Returns an error if the key was not found.
pub fn delete_cf(&mut self, cf: ColumnFamily, key: &[u8]) -> Result<(), Error>
Trait Implementations§
Source§impl Default for WriteBatch
impl Default for WriteBatch
Source§fn default() -> WriteBatch
fn default() -> WriteBatch
Returns the “default value” for a type. Read more
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
Mutably borrows from an owned value. Read more