Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Firestore for Rust

Library provides a simple API for Google Firestore based on the official gRPC API:

  • Fluent high-level and strongly typed API, the only public API of this library;
  • Create or update documents using Rust structures and Serde;
  • Support for:
    • Querying/streaming docs/objects;
    • Listing documents/objects (stream_all follows the page tokens for you);
    • Listening changes from Firestore, with targets added and removed on a running listener and an opt-in idle reset for silent streams;
    • Transactions;
    • Aggregated queries: count, sum, avg;
    • Streaming batch writes with automatic throttling to stay under the Firestore write rate limits;
    • K-nearest neighbour (KNN) vector search with Euclidean, Cosine and Dot Product measures;
    • Query cursors and partition queries;
    • Collection group queries and listing collection IDs;
    • Server side document transforms: increment, array append/remove, server timestamp;
    • Update/delete preconditions;
    • Consistency selectors to read at a given time or inside a transaction;
    • Explaining queries: Core queries on the Standard edition, pipelines and SQL on the Enterprise edition;
    • Request tags to attribute Firestore usage;
    • Opt-in request timeouts;
  • On the Enterprise edition of Firestore:
  • Full async based on Tokio runtime;
  • Macros that help you use your structure fields as Firestore field paths;
  • Implements own Serde serializer to Firestore protobuf values;
  • Support for multiple database IDs;
  • Support for extended datatypes:
    • Firestore timestamp as a FirestoreTimestamp type or with #[serde(with)] attributes (based on jiff);
    • Lat/Lng;
    • References;
    • Explicit nulls;
  • Caching support for collections and documents, for Core reads and for pipeline and SQL reads:
    • In-memory cache;
    • Persistent cache;
  • Declarative index management behind an opt-in admin feature: composite indexes (including one-field, unique and sparse ones), vector indexes, text and geo search indexes, single-field overrides and TTL policy, planned and synced with one call, following the edition of the database;
  • Bulk delete behind the same admin feature: removes every document in named collection groups, at any depth across the whole database, in the background;
  • Works with the Firestore emulator through FIRESTORE_EMULATOR_HOST, no credentials needed;
  • Google client based on gcloud-sdk library that automatically detects GCE environment or application default accounts for local development;