Struct Config

Source
pub struct Config(/* private fields */);
Expand description

Top-level configuration for the system.

§Examples

let _config = sled::Config::default()
    .path("/path/to/data".to_owned())
    .cache_capacity(10_000_000_000)
    .flush_every_ms(Some(1000))
    .snapshot_after_ops(100_000);
// Read-only mode
let _config = sled::Config::default()
    .path("/path/to/data".to_owned())
    .read_only(true);

Implementations§

Source§

impl Config

Source

pub fn new() -> Config

Returns a default Config

Source

pub fn path<P>(self, path: P) -> Config
where P: AsRef<Path>,

Set the path of the database (builder).

Source

pub fn open(&self) -> Result<Db, Error>

Opens a Db based on the provided config.

Source

pub fn temporary(self, to: bool) -> Config

deletes the database after drop. if no path is set, uses /dev/shm on linux

Source

pub fn read_only(self, to: bool) -> Config

whether to run in read-only mode

Source

pub fn cache_capacity(self, to: u64) -> Config

maximum size for the system page cache

Source

pub fn use_compression(self, to: bool) -> Config

whether to use zstd compression

Source

pub fn compression_factor(self, to: i32) -> Config

the compression factor to use with zstd compression

Source

pub fn flush_every_ms(self, to: Option<u64>) -> Config

number of ms between IO buffer flushes

Source

pub fn snapshot_after_ops(self, to: u64) -> Config

number of operations between page table snapshots

Source

pub fn segment_cleanup_threshold(self, to: u8) -> Config

the proportion of remaining valid pages in the segment before GC defragments it

Source

pub fn segment_cleanup_skew(self, to: usize) -> Config

the cleanup threshold skew in percentage points between the first and last segments

Source

pub fn segment_mode(self, to: SegmentMode) -> Config

the file segment selection mode

Source

pub fn snapshot_path(self, to: Option<PathBuf>) -> Config

snapshot file location

Source

pub fn print_profile_on_drop(self, to: bool) -> Config

print a performance profile when the Config is dropped

Source

pub fn idgen_persist_interval(self, to: u64) -> Config

generated IDs are persisted at this interval. during recovery we skip twice this number

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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 Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Config

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

impl Deref for Config

Source§

type Target = Inner

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Inner

Dereferences the value.

Auto Trait Implementations§

§

impl Freeze for Config

§

impl !RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl !UnwindSafe for Config

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.