Trait Db

Source
pub trait Db {
Show 13 methods // Required methods fn txn(&self) -> Transaction; fn group(&self, spec: GroupSpec) -> Box<dyn Group>; fn cursor(&self) -> NewCursor; fn doc_get(&self, doc: &Hash) -> Result<Option<Arc<Document>>, Box<DbError>>; fn query(&self, doc: &Hash, query: DbQuery) -> Box<dyn CursorQuery>; fn schema_get( &self, schema: &Hash, ) -> Result<Option<Arc<Schema>>, Box<DbError>>; fn schema_add( &self, schema: Arc<Document>, ) -> Result<Result<Arc<Schema>, FogError>, Box<DbError>>; fn schema_del(&self, schema: &Hash) -> Result<bool, Box<DbError>>; fn schema_list(&self) -> Vec<Hash>; fn name_get(&self, name: &str) -> Result<Option<Hash>, Box<DbError>>; fn name_add( &self, name: &str, hash: &Hash, ) -> Result<Option<Hash>, Box<DbError>>; fn name_del(&self, schema: &Hash) -> Result<Option<Hash>, Box<DbError>>; fn name_list(&self) -> Vec<(String, Hash)>;
}
Expand description

An implementation of a fog-pack database. Provides cursor, transaction, schema, group, and name access.

  • Transactions may be executed upon by calling Db::txn.
  • Groups may be opened through the database by calling Db::group.
  • Schemas may be added, retrieved, and removed from the database.
  • Name-to-Document mappings may be added, retrieved, and removed from the database. These mappings function as the roots of the database’s Document tree, pinning documents to the database.

Required Methods§

Source

fn txn(&self) -> Transaction

Start a new transaction with this database

Source

fn group(&self, spec: GroupSpec) -> Box<dyn Group>

Open a new group through this database

Source

fn cursor(&self) -> NewCursor

Open a local cursor on this database

Source

fn doc_get(&self, doc: &Hash) -> Result<Option<Arc<Document>>, Box<DbError>>

Get a document directly from the database

Source

fn query(&self, doc: &Hash, query: DbQuery) -> Box<dyn CursorQuery>

Make a query directly on the database

Source

fn schema_get(&self, schema: &Hash) -> Result<Option<Arc<Schema>>, Box<DbError>>

Get a schema in the database

Source

fn schema_add( &self, schema: Arc<Document>, ) -> Result<Result<Arc<Schema>, FogError>, Box<DbError>>

Add a schema to the database. Fails if the schema document wasn’t valid.

Source

fn schema_del(&self, schema: &Hash) -> Result<bool, Box<DbError>>

Remove a schema from the database. Returns false if the schema wasn’t in the database.

Source

fn schema_list(&self) -> Vec<Hash>

Get a list of all schemas in the database.

Source

fn name_get(&self, name: &str) -> Result<Option<Hash>, Box<DbError>>

Get a hash associated with a name in the database.

Source

fn name_add( &self, name: &str, hash: &Hash, ) -> Result<Option<Hash>, Box<DbError>>

Add a name-to-hash mapping to the database. This pins the document inside the database, once it’s been added. This should be done before adding the document in a transaction. Returns the previous hash, if there was one.

Source

fn name_del(&self, schema: &Hash) -> Result<Option<Hash>, Box<DbError>>

Remove a name-hash mapping from the database, returning None if there wasn’t one stored.

Source

fn name_list(&self) -> Vec<(String, Hash)>

Get a list of all named documents in the database.

Implementors§