Expand description
§spn-client
Client library for communicating with the spn daemon.
This crate provides a simple interface for applications (like Nika) to securely retrieve secrets from the spn daemon without directly accessing the OS keychain.
§Usage
use spn_client::{SpnClient, ExposeSecret};
// Connect to the daemon
let mut client = SpnClient::connect().await?;
// Get a secret
let api_key = client.get_secret("anthropic").await?;
println!("Got key: {}", api_key.expose_secret());
// Check if a secret exists
if client.has_secret("openai").await? {
println!("OpenAI key available");
}
// List all providers
let providers = client.list_providers().await?;
println!("Available providers: {:?}", providers);§Fallback Mode
If the daemon is not running, the client can fall back to reading from environment variables:
use spn_client::SpnClient;
let mut client = SpnClient::connect_with_fallback().await?;
// Works even if daemon is not runningStructs§
- SpnClient
- Client for communicating with the spn daemon.
Enums§
- Error
- Errors that can occur when communicating with the spn daemon.
- Request
- Request sent to the daemon.
- Response
- Response from the daemon.
Traits§
- Expose
Secret - Expose a reference to an inner secret
Functions§
- daemon_
socket_ exists - Check if the daemon socket exists.
- default_
socket_ path - Default socket path for the spn daemon.
Type Aliases§
- Secret
String - Secret string type.