pub struct WriteOptions { /* private fields */ }
Expand description

Optionally disable WAL or sync for this write.

Examples

Making an unsafe write of a batch:

use ckb_rocksdb::{DB, Options, WriteBatch, WriteOptions, prelude::*};

let path = "_path_for_rocksdb_storageZ";
{
    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");

    let mut write_options = WriteOptions::default();
    write_options.set_sync(false);
    write_options.disable_wal(true);

    db.write_opt(&batch, &write_options);
}
let _ = DB::destroy(&Options::default(), path);

Implementations§

source§

impl WriteOptions

source

pub fn new() -> WriteOptions

source

pub fn set_sync(&mut self, sync: bool)

Sets the sync mode. If true, the write will be flushed from the operating system buffer cache before the write is considered complete. If this flag is true, writes will be slower.

Default: false

source

pub fn disable_wal(&mut self, disable: bool)

Sets whether WAL should be active or not. If true, writes will not first go to the write ahead log, and the write may got lost after a crash.

Default: false

Trait Implementations§

source§

impl Clone for WriteOptions

source§

fn clone(&self) -> WriteOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for WriteOptions

source§

fn default() -> WriteOptions

Returns the “default value” for a type. Read more
source§

impl DeleteCF<WriteOptions> for TransactionDB

source§

fn delete_cf_full<K>( &self, cf: Option<&ColumnFamily>, key: K, writeopts: Option<&WriteOptions> ) -> Result<(), Error>where K: AsRef<[u8]>,

source§

fn delete_cf<K>(&self, cf: &ColumnFamily, key: K) -> Result<(), Error>where K: AsRef<[u8]>,

source§

fn put_cf_opt<K>( &self, cf: &ColumnFamily, key: K, writeopts: &W ) -> Result<(), Error>where K: AsRef<[u8]>,

source§

impl Drop for WriteOptions

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Handle<rocksdb_writeoptions_t> for WriteOptions

source§

impl MergeCF<WriteOptions> for TransactionDB

source§

fn merge_cf_full<K, V>( &self, cf: Option<&ColumnFamily>, key: K, value: V, writeopts: Option<&WriteOptions> ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

fn merge_cf<K, V>( &self, cf: &ColumnFamily, key: K, value: V ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

fn merge_cf_opt<K, V>( &self, cf: &ColumnFamily, key: K, value: V, writeopts: &W ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

impl PutCF<WriteOptions> for TransactionDB

source§

fn put_cf_full<K, V>( &self, cf: Option<&ColumnFamily>, key: K, value: V, writeopts: Option<&WriteOptions> ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

fn put_cf<K, V>(&self, cf: &ColumnFamily, key: K, value: V) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

fn put_cf_opt<K, V>( &self, cf: &ColumnFamily, key: K, value: V, writeopts: &W ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

impl Send for WriteOptions

source§

impl Sync for WriteOptions

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DeleteCF<WriteOptions> for Twhere T: Handle<rocksdb_t> + Write,

source§

fn delete_cf_full<K>( &self, cf: Option<&ColumnFamily>, key: K, writeopts: Option<&WriteOptions> ) -> Result<(), Error>where K: AsRef<[u8]>,

source§

fn delete_cf<K>(&self, cf: &ColumnFamily, key: K) -> Result<(), Error>where K: AsRef<[u8]>,

source§

fn put_cf_opt<K>( &self, cf: &ColumnFamily, key: K, writeopts: &W ) -> Result<(), Error>where K: AsRef<[u8]>,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> MergeCF<WriteOptions> for Twhere T: Handle<rocksdb_t> + Write,

source§

fn merge_cf_full<K, V>( &self, cf: Option<&ColumnFamily>, key: K, value: V, writeopts: Option<&WriteOptions> ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

fn merge_cf<K, V>( &self, cf: &ColumnFamily, key: K, value: V ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

fn merge_cf_opt<K, V>( &self, cf: &ColumnFamily, key: K, value: V, writeopts: &W ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

impl<T> PutCF<WriteOptions> for Twhere T: Handle<rocksdb_t> + Write,

source§

fn put_cf_full<K, V>( &self, cf: Option<&ColumnFamily>, key: K, value: V, writeopts: Option<&WriteOptions> ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

fn put_cf<K, V>(&self, cf: &ColumnFamily, key: K, value: V) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

fn put_cf_opt<K, V>( &self, cf: &ColumnFamily, key: K, value: V, writeopts: &W ) -> Result<(), Error>where K: AsRef<[u8]>, V: AsRef<[u8]>,

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.