Skip to main content

WriteOptions

Struct WriteOptions 

Source
pub struct WriteOptions {
    pub durability: DurabilityMode,
}
Expand description

Per-write options passed to commit operations.

WriteOptions lets a single write or batch request a durability level different from the database default. The options are evaluated when the write is accepted; changing a WriteOptions value later has no effect on an already committed write.

§Examples

use trine_kv::{Db, WriteOptions};

let db = Db::open_sync(trine_kv::DbOptions::memory())?;
let commit = db.put_with_options_sync(b"k", b"v", WriteOptions::sync_all())?;
assert!(commit.sequence().get() > 0);

Fields§

§durability: DurabilityMode

Durability requested for this write.

Implementations§

Source§

impl WriteOptions

Source

pub const fn new(durability: DurabilityMode) -> Self

Creates write options with an explicit durability mode.

§Parameters
  • durability: durability requested for the write or batch.
Source

pub const fn buffered() -> Self

Creates buffered write options.

The write may return after bytes are accepted by the storage backend but before a flush or sync is requested. This is the lowest-latency and weakest durability mode.

Source

pub const fn flush() -> Self

Creates flush write options.

The write requests a backend flush for accepted WAL bytes. Exact meaning depends on the selected backend capabilities.

Source

pub const fn sync_data() -> Self

Creates data-sync write options.

The write requests durable file data without requiring metadata sync where the backend can distinguish those operations.

Source

pub const fn sync_all() -> Self

Creates full-sync write options.

The write requests the strongest durability mode supported by the backend for WAL data and required metadata.

Trait Implementations§

Source§

impl Clone for WriteOptions

Source§

fn clone(&self) -> WriteOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for WriteOptions

Source§

impl Debug for WriteOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WriteOptions

Source§

fn default() -> WriteOptions

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

impl Eq for WriteOptions

Source§

impl PartialEq for WriteOptions

Source§

fn eq(&self, other: &WriteOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> 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.