pub struct FirestoreCacheConfiguration {
pub collections: HashMap<String, FirestoreCacheCollectionConfiguration>,
pub incomplete_collection_policy: FirestoreCacheIncompleteCollectionPolicy,
}Expand description
Describes which collections a FirestoreCache holds and how each of
them is loaded.
Collections are keyed by their absolute document path (for example
projects/my-project/databases/(default)/documents/users), which is why building a
configuration needs a FirestoreDb to resolve the project and database.
You normally do not construct this directly — the cache builder
(FirestoreCache::memory /
FirestoreCache::persistent) builds it for you.
Fields§
§collections: HashMap<String, FirestoreCacheCollectionConfiguration>The configured collections, keyed by absolute collection path.
incomplete_collection_policy: FirestoreCacheIncompleteCollectionPolicyControls whether collections that are not fully preloaded may serve list/query
requests from the cache. See FirestoreCacheIncompleteCollectionPolicy.
Implementations§
Source§impl FirestoreCacheConfiguration
impl FirestoreCacheConfiguration
Sourcepub fn add_collection_config(
self,
db: &FirestoreDb,
config: FirestoreCacheCollectionConfiguration,
) -> Self
pub fn add_collection_config( self, db: &FirestoreDb, config: FirestoreCacheCollectionConfiguration, ) -> Self
Adds a collection to the configuration.
The db reference is used to resolve the collection’s absolute path.
Sourcepub fn with_incomplete_collection_policy(
self,
incomplete_collection_policy: FirestoreCacheIncompleteCollectionPolicy,
) -> Self
pub fn with_incomplete_collection_policy( self, incomplete_collection_policy: FirestoreCacheIncompleteCollectionPolicy, ) -> Self
Sets the policy for collections that are not fully preloaded.
Sourcepub fn target_change_action(
&self,
target_change: &TargetChange,
) -> FirestoreCacheTargetChangeAction
pub fn target_change_action( &self, target_change: &TargetChange, ) -> FirestoreCacheTargetChangeAction
Decides what a Firestore target change means for the collections of this cache.
A backend’s on_listen_event should act on
this rather than interpreting the target change itself: it resolves Firestore’s “empty
target IDs means all targets” rule, and scopes the result to the documents a target actually
covers.
Sourcepub fn is_document_cached(
&self,
collection_path: &str,
document_id: &str,
) -> bool
pub fn is_document_cached( &self, collection_path: &str, document_id: &str, ) -> bool
Whether the cache holds this document: its collection is cached, and the collection is not restricted to a different set of document IDs.
Sourcepub fn is_collection_listable(&self, collection_path: &str) -> bool
pub fn is_collection_listable(&self, collection_path: &str) -> bool
Returns true when the cache is configured to hold a complete copy of the collection at
collection_path, meaning list and query requests may be served from the cache.
Only preloaded collections (PreloadAllDocs
/ PreloadAllIfEmpty) qualify. A
PreloadNone collection holds an
arbitrary subset of documents — whatever happens to have been read through it so far — so
serving a listing from it would silently return partial results.
This can be relaxed with
FirestoreCacheIncompleteCollectionPolicy::PartialResults.
Trait Implementations§
Source§impl Clone for FirestoreCacheConfiguration
impl Clone for FirestoreCacheConfiguration
Source§impl Debug for FirestoreCacheConfiguration
impl Debug for FirestoreCacheConfiguration
Auto Trait Implementations§
impl Freeze for FirestoreCacheConfiguration
impl RefUnwindSafe for FirestoreCacheConfiguration
impl Send for FirestoreCacheConfiguration
impl Sync for FirestoreCacheConfiguration
impl Unpin for FirestoreCacheConfiguration
impl UnsafeUnpin for FirestoreCacheConfiguration
impl UnwindSafe for FirestoreCacheConfiguration
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request