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
impl Db
pub fn listen_tcp(&self, addr: impl ToSocketAddrsAsync + Send + 'static)
pub fn listen_uds(&self, path: impl AsRef<Path> + Send + 'static)
Source§impl Db
impl Db
pub fn open(path: impl AsRef<Path>) -> DbResult<Self>
pub fn open_with_compaction( path: impl AsRef<Path>, compaction_interval: Option<Duration>, ) -> DbResult<Self>
pub fn tree_path(&self, name: &str, version: u16) -> PathBuf
Sourcepub fn next_id(&self, name: &str) -> DbResult<u64>
pub fn next_id(&self, name: &str) -> DbResult<u64>
Generate the next sequential ID for a named collection.
Sourcepub fn collection_len<T: CollectionMeta>(&self) -> u64
pub fn collection_len<T: CollectionMeta>(&self) -> u64
Get the last saved collection length from db.info.
Sourcepub fn close(&self) -> DbResult<()>
pub fn close(&self) -> DbResult<()>
Flush all collection lengths to db.info and flush the sequence generator.
Sourcepub fn open_typed_tree<T, C>(
&self,
config: Config,
migrations: &[TypedMigration<T::SelfId, T>],
) -> DbResult<Arc<TypedTree<T::SelfId, T, C>>>
pub fn open_typed_tree<T, C>( &self, config: Config, migrations: &[TypedMigration<T::SelfId, T>], ) -> DbResult<Arc<TypedTree<T::SelfId, T, C>>>
Open a TypedTree with auto-migration.
Sourcepub 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>>>
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>>>
Open a TypedTree with a write hook.
Sourcepub fn open_typed_map<T, C>(
&self,
config: Config,
migrations: &[TypedMigration<T::SelfId, T>],
) -> DbResult<Arc<TypedMap<T::SelfId, T, C>>>
pub fn open_typed_map<T, C>( &self, config: Config, migrations: &[TypedMigration<T::SelfId, T>], ) -> DbResult<Arc<TypedMap<T::SelfId, T, C>>>
Open a TypedMap with auto-migration.
Sourcepub 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>>>
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>>>
Open a TypedMap with a write hook.
Sourcepub fn open_zero_tree<T, const V: usize>(
&self,
config: Config,
migrations: &[ZeroMigration<T::SelfId, T>],
) -> DbResult<Arc<ZeroTree<T::SelfId, V, Bitcask, T>>>
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>>>
Open a ZeroTree with auto-migration.
Sourcepub 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>>>
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>>>
Open a ZeroTree with a write hook.
Sourcepub fn open_zero_map<T, const V: usize>(
&self,
config: Config,
migrations: &[ZeroMigration<T::SelfId, T>],
) -> DbResult<Arc<ZeroMap<T::SelfId, V, Bitcask, T>>>
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>>>
Open a ZeroMap with auto-migration.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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