Struct OpenOptions

Source
pub struct OpenOptions { /* private fields */ }
Expand description

Options used to configured how an Index is opened.

Similar to std::fs::OpenOptions, to use this, first call new, then chain calls to methods to set each option, finally call open to get an Index structure.

Implementations§

Source§

impl OpenOptions

Source

pub fn new() -> OpenOptions

Create OpenOptions with default configuration:

  • checksum enabled, with 1MB chunk size
  • checksum max chain length is config::INDEX_CHECKSUM_MAX_CHAIN_LEN (default: 10)
  • no external key buffer
  • no fsync
  • read root entry from the end of the file
  • open as read-write but fallback to read-only
Source

pub fn checksum_max_chain_len(&mut self, len: u32) -> &mut Self

Set the maximum checksum chain length.

If it is non-zero, and the checksum chain (linked list of checksum entries needed to verify the entire index) exceeds the specified length, they will be collapsed into a single checksum entry to make open more efficient.

Source

pub fn checksum_chunk_size_logarithm( &mut self, checksum_chunk_size_logarithm: u32, ) -> &mut Self

Set checksum chunk size as 1 << checksum_chunk_size_logarithm.

Source

pub fn checksum_enabled(&mut self, checksum_enabled: bool) -> &mut Self

Set whether to write checksum entries on flush.

Source

pub fn fsync(&mut self, fsync: bool) -> &mut Self

Set fsync behavior.

If true, then Index::flush will use fsync to flush data to the physical device before returning.

Source

pub fn write(&mut self, value: Option<bool>) -> &mut Self

Set whether writing is required:

  • None: open as read-write but fallback to read-only. flush() may fail.
  • Some(false): open as read-only. flush() will always fail.
  • Some(true): open as read-write. open() fails if read-write is not possible. flush() will not fail due to permission issues.

Note: The index is always mutable in-memory. Only flush() may fail.

Source

pub fn logical_len(&mut self, len: Option<u64>) -> &mut Self

Specify the logical length of the file.

If len is None, use the actual file length. Otherwise, use the length specified by len. Reading the file length requires locking.

This is useful for lock-free reads, or accessing to multiple versions of the index at the same time.

To get a valid logical length, check the return value of Index::flush.

Source

pub fn key_buf( &mut self, buf: Option<Arc<dyn ReadonlyBuffer + Send + Sync>>, ) -> &mut Self

Specify the external key buffer.

With an external key buffer, keys could be stored as references using index.insert_advanced to save space.

Source

pub fn open<P: AsRef<Path>>(&self, path: P) -> Result<Index>

Open the index file with given options.

Driven by the “immutable by default” idea, together with append-only properties, OpenOptions::open returns a “snapshotted” view of the index. Changes to the filesystem won’t change instantiated Indexes.

Source

pub fn create_in_memory(&self) -> Result<Index>

Create an in-memory Index that skips flushing to disk. Return an error if checksum_chunk_size_logarithm is not 0.

Trait Implementations§

Source§

impl Clone for OpenOptions

Source§

fn clone(&self) -> OpenOptions

Returns a duplicate 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 Debug for OpenOptions

Source§

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

Formats the value using the given formatter. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more