Trait Cursor

Source
pub trait Cursor {
    // Required methods
    fn forward<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        hash: &'life1 Hash,
    ) -> Pin<Box<dyn Future<Output = Result<Arc<Document>, CursorError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn forward_local(
        &mut self,
        hash: &Hash,
    ) -> Result<Option<Arc<Document>>, CursorError>;
    fn back(&mut self) -> Result<(), CursorBackError>;
    fn fork(&self) -> Box<dyn ForkCursor>;
    fn current(&self) -> Arc<Document>;
    fn query(self: Box<Self>, query: DbQuery) -> Box<dyn CursorQuery>;

    // Provided method
    fn fork_local(&self) -> Result<Option<NewCursor>, CursorError> { ... }
}
Expand description

A cursor for navigating through a database.

A cursor is opened through a specific Gate or on the local database, and permits navigation through the database by following Document Hashes or making queries against Documents.

Required Methods§

Source

fn forward<'life0, 'life1, 'async_trait>( &'life0 mut self, hash: &'life1 Hash, ) -> Pin<Box<dyn Future<Output = Result<Arc<Document>, CursorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Move the cursor forward by navigating to one of the documents linked to by the current document. Fails if the requested document hash isn’t in the current document, or if the returned data hashes correctly but isn’t a valid fog-pack document.

Source

fn forward_local( &mut self, hash: &Hash, ) -> Result<Option<Arc<Document>>, CursorError>

Move the cursor forward only if the requested document is in the local database. Can fail for the same reasons as forward but may also return None if the local database doesn’t have said document.

Source

fn back(&mut self) -> Result<(), CursorBackError>

Move the cursor back up a level. Fails if the cursor is already at the earliest point in its history.

Source

fn fork(&self) -> Box<dyn ForkCursor>

Fork the cursor. Works like forward but produces a new cursor in the process - one that starts from the document it navigated to.

Source

fn current(&self) -> Arc<Document>

Return the document the cursor is currently on.

Source

fn query(self: Box<Self>, query: DbQuery) -> Box<dyn CursorQuery>

Make a query on the current document.

Provided Methods§

Source

fn fork_local(&self) -> Result<Option<NewCursor>, CursorError>

Fork the cursor. Works like forward_local but produces a new cursor in the process - one that starts from the document it navigated to.

Implementors§