Struct schemadb::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: Vec<ColumnFamilyName>, db_opts: Options ) -> Result<Self>

Create db with all the column families provided if it doesn’t exist at path; Otherwise, try to open it with all the column families.

source

pub fn open_readonly( path: impl AsRef<Path>, name: &'static str, column_families: Vec<ColumnFamilyName>, db_opts: Options ) -> Result<Self>

Open db in readonly mode Note that this still assumes there’s only one process that opens the same DB. See open_as_secondary

source

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

Reads single record by key.

source

pub fn put<S: Schema>(&self, key: &S::Key, value: &S::Value) -> Result<()>

Writes single record.

source

pub fn range_delete<S, SK>(&self, begin: &SK, end: &SK) -> Result<()>
where S: Schema, SK: SeekKeyCodec<S>,

Delete all keys in range [begin, end).

SK has to be an explicit type parameter since https://github.com/rust-lang/rust/issues/44721

source

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

Returns a forward SchemaIterator on a certain schema.

source

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

Returns a backward SchemaIterator on a certain schema.

source

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

Writes a group of records wrapped in a SchemaBatch.

source

pub fn flush_all(&self, sync: bool) -> Result<()>

Flushes all 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>

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

§

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

§

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