Expand description
§Zinit Client
A Rust client library for interacting with the Zinit service manager.
§Features
- Complete API coverage for all Zinit operations
- Robust error handling with custom error types
- Automatic reconnection on socket errors
- Retry mechanisms for transient failures
- Async/await support using Tokio
- Strongly typed service states and responses
- Efficient log streaming
§Usage
use zinit_client::{ZinitClient, Result};
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<()> {
// Create a client with default configuration
let client = ZinitClient::new("/var/run/zinit.sock");
// List all services
let services = client.list().await?;
println!("Services: {:?}", services);
// Start a service
client.start("nginx").await?;
// Get service status
let status = client.status("nginx").await?;
println!("Nginx status: {:?}", status);
Ok(())
}
§Configuration
You can customize the client behavior using ClientConfig
:
use zinit_client::{ZinitClient, ClientConfig};
use std::time::Duration;
let config = ClientConfig {
socket_path: "/var/run/zinit.sock".into(),
connection_timeout: Duration::from_secs(5),
operation_timeout: Duration::from_secs(30),
max_retries: 3,
retry_delay: Duration::from_millis(100),
max_retry_delay: Duration::from_secs(5),
retry_jitter: true,
};
let client = ZinitClient::with_config(config);
Structs§
- Client
Config - Configuration for the Zinit client
- LogEntry
- Log entry from a service
- LogStream
- Stream of log entries
- Retry
Strategy - Strategy for retrying operations
- Service
Status - Service status information
- Zinit
Client - Client for interacting with Zinit
Enums§
- Service
State - Service state
- Service
Target - Service target state
- Zinit
Error - Custom error types for the Zinit client
Traits§
- Stream
Ext - An extension trait for
Stream
s that provides a variety of convenient combinator functions.
Type Aliases§
- Result
- Result type for Zinit client operations