Crates.io | spicedb-client |
lib.rs | spicedb-client |
version | 0.1.1 |
source | src |
created_at | 2024-08-10 23:37:00.606363 |
updated_at | 2024-08-10 23:37:00.606363 |
description | Ergonomic Rust gRPC client for SpiceDB |
homepage | |
repository | https://github.com/lunaetco/spicedb-grpc |
max_upload_size | |
id | 1332809 |
size | 34,645 |
Experimental ergonomic(-ish) Rust client for the SpiceDB gRPC API.
[!WARNING] Experimental!
Add this to your Cargo.toml
:
[dependencies]
spicedb-client = "0.1.1"
use spicedb_client::SpicedbClient;
use spicedb_client::reader::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let spicedb_url = std::env::var("SPICEDB_URL")
.unwrap_or_else(|_| "http://localhost:50051".to_string());
let preshared_key = std::env::var("SPICEDB_PRESHARED_KEY")
.unwrap_or_else(|_| "spicedb".to_string());
let mut client = SpicedbClient::from_url_and_preshared_key(spicedb_url, preshared_key)
.await
.unwrap();
// Read schema
let response = client.read_schema().await.unwrap();
let schema = response.schema_text();
println!("Schema: {:?}", schema);
Ok(())
}
We welcome contributions!
This project is licensed under Apache 2.0.
This client is based on the official AuthZed SpiceDB API and uses Tonic for to generate the gRPC client.