5 releases (breaking)
Uses new Rust 2024
| 0.5.0 | Dec 7, 2025 |
|---|---|
| 0.4.0 | Oct 26, 2025 |
| 0.3.0 | Oct 10, 2025 |
| 0.2.0 | Oct 10, 2025 |
| 0.1.0 | Oct 9, 2025 |
#1130 in Command line utilities
25KB
218 lines
Firestore Client Rust
This is a Rust command-line interface (CLI) application designed for basic interaction with Google Cloud Firestore. It provides a simple way to manage product data within a Firestore collection named "inventory".
Features
- Seed Database: Populate your Firestore "inventory" collection with sample product data.
- List Products: Retrieve and display all products currently stored in the "inventory" collection.
- Get Product by ID: Fetch a specific product from the "inventory" collection using its unique ID.
Technologies Used
- Rust: The programming language.
- Google Cloud Firestore: NoSQL document database.
firestorecrate: Rust client library for Firestore.tokio: Asynchronous runtime for Rust.serde: Serialization and deserialization framework.clap: Command-line argument parser.anyhow: Flexible error handling.dotenv: Loads environment variables from a.envfile.tracing: Application-level tracing for observability.
Setup and Usage
Prerequisites
- Rust and Cargo installed.
- Google Cloud Project with Firestore enabled.
- Service Account Key for Firestore authentication (usually handled by
gcloud auth application-default loginorGOOGLE_APPLICATION_CREDENTIALSenvironment variable).
Environment Variables
Create a .env file in the project root with your Google Cloud Project ID:
PROJECT_ID=your-gcp-project-id
Building the Application
cargo build --release
Running Commands
Seed the database
cargo run --release seed
List all products
cargo run --release list
Get a product by ID
Replace <product_id> with the actual ID of a product.
cargo run --release get <product_id>
Project Structure
src/main.rs: Contains the main application logic, including product data structures, Firestore interaction functions, and CLI command handling.Cargo.toml: Defines project dependencies and metadata.Cargo.lock: Records the exact versions of dependencies.
License
This project is licensed under the MIT OR Apache-2.0 License. See the Cargo.toml file for more details.
Dependencies
~127MB
~2M SLoC