Skip to main content

Db

Struct Db 

Source
pub struct Db {
    pub path: PathBuf,
    pub db_info: Persist<DbInfo>,
    pub seq: Arc<SeqGen>,
    /* private fields */
}
Expand description

Manager for multiple named trees with persistent metadata and sequence generation.

Fields§

§path: PathBuf§db_info: Persist<DbInfo>§seq: Arc<SeqGen>

Implementations§

Source§

impl Db

Source

pub fn listen_tcp(&self, addr: impl ToSocketAddrsAsync + Send + 'static)

Source

pub fn listen_uds(&self, path: impl AsRef<Path> + Send + 'static)

Source§

impl Db

Source

pub fn open(path: impl AsRef<Path>) -> DbResult<Self>

Source

pub fn open_with_compaction( path: impl AsRef<Path>, compaction_interval: Option<Duration>, ) -> DbResult<Self>

Source

pub fn tree_path(&self, name: &str, version: u16) -> PathBuf

Source

pub fn next_id(&self, name: &str) -> DbResult<u64>

Generate the next sequential ID for a named collection.

Source

pub fn collection_len<T: CollectionMeta>(&self) -> u64

Get the last saved collection length from db.info.

Source

pub fn close(&self) -> DbResult<()>

Flush all collection lengths to db.info and flush the sequence generator.

Source

pub fn compact(&self) -> DbResult<usize>

Trigger a compaction pass for all collections.

Source

pub fn open_typed_tree<T, C>( &self, config: Config, migrations: &[TypedMigration<T::SelfId, T>], ) -> DbResult<Arc<TypedTree<T::SelfId, T, C>>>
where T: CollectionMeta + Clone + Send + Sync + 'static, T::SelfId: Key + Ord + Send + Sync, C: Codec<T> + Default + 'static,

Open a TypedTree with auto-migration.

Source

pub fn open_typed_tree_hooked<T, C, H>( &self, config: Config, hook: H, migrations: &[TypedMigration<T::SelfId, T>], ) -> DbResult<Arc<TypedTree<T::SelfId, T, C, H>>>
where T: CollectionMeta + Clone + Send + Sync + 'static, T::SelfId: Key + Ord + Send + Sync, C: Codec<T> + Default + 'static, H: TypedWriteHook<T::SelfId, T> + 'static,

Open a TypedTree with a write hook.

Source

pub fn open_typed_map<T, C>( &self, config: Config, migrations: &[TypedMigration<T::SelfId, T>], ) -> DbResult<Arc<TypedMap<T::SelfId, T, C>>>
where T: CollectionMeta + Clone + Send + Sync + 'static, T::SelfId: Key + Send + Sync + Hash + Eq, C: Codec<T> + Default + 'static,

Open a TypedMap with auto-migration.

Source

pub fn open_typed_map_hooked<T, C, H>( &self, config: Config, hook: H, migrations: &[TypedMigration<T::SelfId, T>], ) -> DbResult<Arc<TypedMap<T::SelfId, T, C, H>>>
where T: CollectionMeta + Clone + Send + Sync + 'static, T::SelfId: Key + Send + Sync + Hash + Eq, C: Codec<T> + Default + 'static, H: TypedWriteHook<T::SelfId, T> + 'static,

Open a TypedMap with a write hook.

Source

pub fn open_zero_tree<T, const V: usize>( &self, config: Config, migrations: &[ZeroMigration<T::SelfId, T>], ) -> DbResult<Arc<ZeroTree<T::SelfId, V, Bitcask, T>>>
where T: CollectionMeta + Copy + Send + Sync + 'static, T::SelfId: Key + Ord + Send + Sync,

Open a ZeroTree with auto-migration.

Source

pub fn open_zero_tree_hooked<T, const V: usize, H>( &self, config: Config, hook: H, migrations: &[ZeroMigration<T::SelfId, T>], ) -> DbResult<Arc<ZeroTree<T::SelfId, V, Bitcask, T, H>>>
where T: CollectionMeta + Copy + Send + Sync + 'static, T::SelfId: Key + Ord + Send + Sync, H: TypedWriteHook<T::SelfId, T> + 'static,

Open a ZeroTree with a write hook.

Source

pub fn open_zero_map<T, const V: usize>( &self, config: Config, migrations: &[ZeroMigration<T::SelfId, T>], ) -> DbResult<Arc<ZeroMap<T::SelfId, V, Bitcask, T>>>
where T: CollectionMeta + Copy + Send + Sync + 'static, T::SelfId: Key + Send + Sync + Hash + Eq,

Open a ZeroMap with auto-migration.

Source

pub fn open_zero_map_hooked<T, const V: usize, H>( &self, config: Config, hook: H, migrations: &[ZeroMigration<T::SelfId, T>], ) -> DbResult<Arc<ZeroMap<T::SelfId, V, Bitcask, T, H>>>
where T: CollectionMeta + Copy + Send + Sync + 'static, T::SelfId: Key + Send + Sync + Hash + Eq, H: TypedWriteHook<T::SelfId, T> + 'static,

Open a ZeroMap with a write hook.

Source§

impl Db

Source

pub fn build_tree_map(&self) -> TreeMap

Build the RPC routing table from all registered handlers.

Trait Implementations§

Source§

impl Drop for Db

Source§

fn drop(&mut self)

Executes the destructor for this type. 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 UnsafeUnpin 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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<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