Struct WriteOptions

Source
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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DeleteCF<WriteOptions> for T
where 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 T
where 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 T
where 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.