Skip to content

Rust Configuration

The Rust SDK uses a builder pattern for configuration:

use flags_rs::{Auth, Client};
let client = Client::builder()
.with_auth(Auth {
project_id: "your-project-id".to_string(),
agent_id: "your-agent-id".to_string(),
environment_id: "your-environment-id".to_string(),
})
.with_base_url("https://custom-api.flags.gg")
.with_max_retries(5)
.with_memory_cache()
.build();
MethodDefaultDescription
with_auth(Auth)Required. Set authentication credentials
with_base_url(&str)https://api.flags.ggCustom API endpoint
with_max_retries(u32)3Max retry attempts
with_memory_cache()MemoryUse in-memory cache

The SDK defines a FlagError enum:

VariantDescription
HttpErrorNetwork or HTTP errors
CacheErrorCache operation errors
AuthErrorAuthentication errors
ApiErrorAPI response errors
BuilderErrorConfiguration errors

The client gracefully degrades — it falls back to cached or default values rather than panicking.

The SDK uses tokio for async operations. All flag checks and list operations are async:

let enabled = client.is("flag").enabled().await;
let flags = client.list().await?;