Skip to main content

Adapter

Trait Adapter 

Source
pub trait Adapter: Send + Sync {
Show 19 methods // Required methods fn info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<DbInfo>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, opts: GetOptions, ) -> Pin<Box<dyn Future<Output = Result<Document>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn bulk_docs<'life0, 'async_trait>( &'life0 self, docs: Vec<Document>, opts: BulkDocsOptions, ) -> Pin<Box<dyn Future<Output = Result<Vec<DocResult>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn all_docs<'life0, 'async_trait>( &'life0 self, opts: AllDocsOptions, ) -> Pin<Box<dyn Future<Output = Result<AllDocsResponse>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn changes<'life0, 'async_trait>( &'life0 self, opts: ChangesOptions, ) -> Pin<Box<dyn Future<Output = Result<ChangesResponse>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn revs_diff<'life0, 'async_trait>( &'life0 self, revs: HashMap<String, Vec<String>>, ) -> Pin<Box<dyn Future<Output = Result<RevsDiffResponse>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn bulk_get<'life0, 'async_trait>( &'life0 self, docs: Vec<BulkGetItem>, ) -> Pin<Box<dyn Future<Output = Result<BulkGetResponse>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn put_attachment<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, doc_id: &'life1 str, att_id: &'life2 str, rev: &'life3 str, data: Vec<u8>, content_type: &'life4 str, ) -> Pin<Box<dyn Future<Output = Result<DocResult>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait; fn get_attachment<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, doc_id: &'life1 str, att_id: &'life2 str, opts: GetAttachmentOptions, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn remove_attachment<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, doc_id: &'life1 str, att_id: &'life2 str, rev: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<DocResult>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn get_local<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn put_local<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, doc: Value, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn remove_local<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn compact<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn destroy<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided methods fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn purge<'life0, 'async_trait>( &'life0 self, _req: HashMap<String, Vec<String>>, ) -> Pin<Box<dyn Future<Output = Result<PurgeResponse>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_security<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<SecurityDocument>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn put_security<'life0, 'async_trait>( &'life0 self, _doc: SecurityDocument, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

The trait all storage adapters must implement.

This mirrors PouchDB’s internal adapter interface (underscore-prefixed methods in JavaScript). Each method corresponds to a CouchDB API endpoint.

Adapters are responsible for:

  • Storing and retrieving documents with full revision tree support
  • Tracking sequence numbers for the changes feed
  • Managing local (non-replicated) documents for checkpoints
  • Attachment storage and retrieval

Required Methods§

Source

fn info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<DbInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get database information: name, document count, update sequence.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, opts: GetOptions, ) -> Pin<Box<dyn Future<Output = Result<Document>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve a single document by ID.

Supports fetching specific revisions, open revisions (all leaves), and including conflict information.

Source

fn bulk_docs<'life0, 'async_trait>( &'life0 self, docs: Vec<Document>, opts: BulkDocsOptions, ) -> Pin<Box<dyn Future<Output = Result<Vec<DocResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Write multiple documents atomically.

When opts.new_edits is true (default), the adapter generates new revision IDs and checks for conflicts.

When opts.new_edits is false (replication mode), the adapter accepts revision IDs as-is and merges them into the existing revision tree without conflict checks.

Source

fn all_docs<'life0, 'async_trait>( &'life0 self, opts: AllDocsOptions, ) -> Pin<Box<dyn Future<Output = Result<AllDocsResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Query all documents, optionally filtered by key range.

Source

fn changes<'life0, 'async_trait>( &'life0 self, opts: ChangesOptions, ) -> Pin<Box<dyn Future<Output = Result<ChangesResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get changes since a given sequence number.

Source

fn revs_diff<'life0, 'async_trait>( &'life0 self, revs: HashMap<String, Vec<String>>, ) -> Pin<Box<dyn Future<Output = Result<RevsDiffResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Compare sets of document revisions to find which ones the adapter is missing. Used during replication to avoid transferring data the target already has.

Source

fn bulk_get<'life0, 'async_trait>( &'life0 self, docs: Vec<BulkGetItem>, ) -> Pin<Box<dyn Future<Output = Result<BulkGetResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch multiple documents by ID and revision in a single request. Used during replication to efficiently retrieve missing documents.

Source

fn put_attachment<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, doc_id: &'life1 str, att_id: &'life2 str, rev: &'life3 str, data: Vec<u8>, content_type: &'life4 str, ) -> Pin<Box<dyn Future<Output = Result<DocResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Store an attachment on a document.

Source

fn get_attachment<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, doc_id: &'life1 str, att_id: &'life2 str, opts: GetAttachmentOptions, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieve raw attachment data.

Source

fn remove_attachment<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, doc_id: &'life1 str, att_id: &'life2 str, rev: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<DocResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Remove an attachment from a document.

Creates a new revision of the document with the attachment removed.

Source

fn get_local<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve a local document (not replicated, used for checkpoints).

Source

fn put_local<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, doc: Value, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Write a local document (not replicated, used for checkpoints).

Source

fn remove_local<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a local document.

Source

fn compact<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Compact the database: remove old revisions, clean up unreferenced attachment data.

Source

fn destroy<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Destroy the database and all its data.

Provided Methods§

Source

fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close the database, releasing any held resources. Default implementation is a no-op.

Source

fn purge<'life0, 'async_trait>( &'life0 self, _req: HashMap<String, Vec<String>>, ) -> Pin<Box<dyn Future<Output = Result<PurgeResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Purge (permanently remove) document revisions.

Source

fn get_security<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<SecurityDocument>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the security document for this database.

Source

fn put_security<'life0, 'async_trait>( &'life0 self, _doc: SecurityDocument, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the security document for this database.

Implementors§