Skip to main content

FirestoreCacheDocsByPathSupport

Trait FirestoreCacheDocsByPathSupport 

Source
pub trait FirestoreCacheDocsByPathSupport {
    // Required methods
    fn get_doc_by_path<'life0, 'life1, 'async_trait>(
        &'life0 self,
        document_path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = FirestoreResult<Option<FirestoreDocument>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update_doc_by_path<'life0, 'life1, 'async_trait>(
        &'life0 self,
        document: &'life1 FirestoreDocument,
    ) -> Pin<Box<dyn Future<Output = FirestoreResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_all_docs<'b, 'life0, 'life1, 'async_trait>(
        &'life0 self,
        collection_path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = FirestoreResult<FirestoreCachedValue<BoxStream<'b, FirestoreResult<FirestoreDocument>>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'b: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn query_docs<'b, 'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        collection_path: &'life1 str,
        query: &'life2 FirestoreQueryParams,
    ) -> Pin<Box<dyn Future<Output = FirestoreResult<FirestoreCachedValue<BoxStream<'b, FirestoreResult<FirestoreDocument>>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'b: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn get_docs_by_paths<'a, 'async_trait>(
        &'a self,
        full_doc_ids: &'a [String],
    ) -> Pin<Box<dyn Future<Output = FirestoreResult<BoxStream<'a, FirestoreResult<(String, Option<FirestoreDocument>)>>>> + Send + 'async_trait>>
       where Self: Sync + Sync + 'async_trait,
             'a: 'async_trait { ... }
}
Expand description

Re-exports all public items from the cache module.

This is only available if the caching feature is enabled. It includes types like FirestoreCache and various caching backends and configurations. Defines support for retrieving and updating cached documents by their full path.

Required Methods§

Source

fn get_doc_by_path<'life0, 'life1, 'async_trait>( &'life0 self, document_path: &'life1 str, ) -> Pin<Box<dyn Future<Output = FirestoreResult<Option<FirestoreDocument>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a single document from the cache by its full Firestore path.

§Arguments
  • document_path: The full path to the document (e.g., “projects/P/databases/D/documents/C/ID”).
§Returns

A FirestoreResult containing an Option<FirestoreDocument>. None if the document is not found in the cache.

Source

fn update_doc_by_path<'life0, 'life1, 'async_trait>( &'life0 self, document: &'life1 FirestoreDocument, ) -> Pin<Box<dyn Future<Output = FirestoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Updates or inserts a document in the cache.

The document’s full path is typically derived from document.name.

§Arguments
§Returns

A FirestoreResult indicating success or failure.

Source

fn list_all_docs<'b, 'life0, 'life1, 'async_trait>( &'life0 self, collection_path: &'life1 str, ) -> Pin<Box<dyn Future<Output = FirestoreResult<FirestoreCachedValue<BoxStream<'b, FirestoreResult<FirestoreDocument>>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'b: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Lists all documents in the cache for a given collection path.

§Arguments
  • collection_path: The full path to the collection (e.g., “projects/P/databases/D/documents/C”).
§Returns

A FirestoreResult containing a FirestoreCachedValue. If UseCached, it holds a stream of FirestoreResult<FirestoreDocument>. If SkipCache, the caller should fetch directly from Firestore.

Source

fn query_docs<'b, 'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection_path: &'life1 str, query: &'life2 FirestoreQueryParams, ) -> Pin<Box<dyn Future<Output = FirestoreResult<FirestoreCachedValue<BoxStream<'b, FirestoreResult<FirestoreDocument>>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'b: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Queries documents in the cache for a given collection path and query parameters.

The backend is responsible for applying the filters and ordering defined in query to its cached data.

§Arguments
§Returns

A FirestoreResult containing a FirestoreCachedValue. If UseCached, it holds a stream of FirestoreResult<FirestoreDocument>. If SkipCache, the caller should fetch directly from Firestore.

Provided Methods§

Source

fn get_docs_by_paths<'a, 'async_trait>( &'a self, full_doc_ids: &'a [String], ) -> Pin<Box<dyn Future<Output = FirestoreResult<BoxStream<'a, FirestoreResult<(String, Option<FirestoreDocument>)>>>> + Send + 'async_trait>>
where Self: Sync + Sync + 'async_trait, 'a: 'async_trait,

Retrieves multiple documents from the cache by their full Firestore paths.

This default implementation iterates over full_doc_ids and calls get_doc_by_path for each. Backends may provide a more optimized batch implementation.

§Arguments
  • full_doc_ids: A slice of full document paths.
§Returns

A FirestoreResult containing a stream of FirestoreResult<(String, Option<FirestoreDocument>)>. The String in the tuple is the document ID (last segment of the path).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§