Struct DB

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

This DB is a schematized RocksDB wrapper where all data passed in and out are typed according to Schemas.

Implementations§

Source§

impl DB

Source

pub fn open( path: impl AsRef<Path>, name: &'static str, column_families: impl IntoIterator<Item = impl Into<String>>, db_opts: &Options, ) -> Result<Self>

Opens a database backed by RocksDB, using the provided column family names and default column family options.

Source

pub fn open_with_cfds( db_opts: &Options, path: impl AsRef<Path>, name: &'static str, cfds: impl IntoIterator<Item = ColumnFamilyDescriptor>, ) -> Result<DB>

Open RocksDB with the provided column family descriptors. This allows to configure options for each column family.

Source

pub fn open_cf_readonly( opts: &Options, path: impl AsRef<Path>, name: &'static str, cfs: Vec<ColumnFamilyName>, ) -> Result<DB>

Open db in readonly mode. This db is completely static, so any writes that occur on the primary after it has been opened will not be visible to the readonly instance.

Source

pub fn open_cf_as_secondary<P: AsRef<Path>>( opts: &Options, primary_path: P, secondary_path: P, name: &'static str, cfs: Vec<ColumnFamilyName>, ) -> Result<DB>

Open db in secondary mode. A secondary db is does not support writes, but can be dynamically caught up to the primary instance by a manual call. See https://github.com/facebook/rocksdb/wiki/Read-only-and-Secondary-instances for more details.

Source

pub fn get<S: Schema>( &self, schema_key: &impl KeyCodec<S>, ) -> Result<Option<S::Value>>

Reads single record by key.

Source

pub fn put<S: Schema>( &self, key: &impl KeyCodec<S>, value: &impl ValueCodec<S>, ) -> Result<()>

Writes single record.

Source

pub fn iter<S: Schema>(&self) -> Result<SchemaIterator<'_, S>>

Returns a forward SchemaIterator on a certain schema with the default read options.

Source

pub fn iter_with_opts<S: Schema>( &self, opts: ReadOptions, ) -> Result<SchemaIterator<'_, S>>

Returns a forward SchemaIterator on a certain schema with the provided read options.

Source

pub fn rev_iter<S: Schema>(&self) -> Result<SchemaIterator<'_, S>>

Returns a backward SchemaIterator on a certain schema with the default read options.

Source

pub fn rev_iter_with_opts<S: Schema>( &self, opts: ReadOptions, ) -> Result<SchemaIterator<'_, S>>

Returns a backward SchemaIterator on a certain schema with the provided read options.

Source

pub fn write_schemas(&self, batch: SchemaBatch) -> Result<()>

Writes a group of records wrapped in a SchemaBatch.

Source

pub fn flush_cf(&self, cf_name: &str) -> Result<()>

Flushes MemTable data. This is only used for testing get_approximate_sizes_cf in unit tests.

Source

pub fn get_property(&self, cf_name: &str, property_name: &str) -> Result<u64>

Returns the current RocksDB property value for the provided column family name and property name.

Source

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

Creates new physical DB checkpoint in directory specified by path.

Trait Implementations§

Source§

impl Debug for DB

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for DB

§

impl RefUnwindSafe for DB

§

impl Send for DB

§

impl Sync for DB

§

impl Unpin for DB

§

impl UnwindSafe for DB

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> 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, 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<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