pub struct ZinitHandle { /* private fields */ }Expand description
Synchronous handle for Rhai functions to use
Implementations§
Source§impl ZinitHandle
impl ZinitHandle
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new handle that connects to the default server. Performs a health check (ping) to verify the connection is working.
§Errors
Returns an error if:
- The default socket path cannot be determined
- The zinit server is not running or not reachable
- The ping request fails
Sourcepub fn new_unchecked() -> Result<Self>
pub fn new_unchecked() -> Result<Self>
Create a new handle without health check (for advanced use cases).
Use this when you want to defer the connection test or handle it manually.
Call test_connection() afterwards to verify the connection.
Sourcepub fn with_socket<P: AsRef<Path>>(socket_path: P) -> Result<Self>
pub fn with_socket<P: AsRef<Path>>(socket_path: P) -> Result<Self>
Create a new handle connecting to a specific socket path. Performs a health check (ping) to verify the connection is working.
§Arguments
socket_path- Path to the Unix socket file
§Errors
Returns an error if:
- The zinit server is not running or not reachable at the specified path
- The ping request fails
Sourcepub fn with_socket_unchecked<P: AsRef<Path>>(socket_path: P) -> Result<Self>
pub fn with_socket_unchecked<P: AsRef<Path>>(socket_path: P) -> Result<Self>
Create a new handle connecting to a specific socket path without health check.
Use this when you want to defer the connection test or handle it manually.
Call test_connection() afterwards to verify the connection.
Sourcepub fn with_client(client: ZinitClient) -> Result<Self>
pub fn with_client(client: ZinitClient) -> Result<Self>
Create a new handle with a specific client
Sourcepub fn with_log_level(self, level: LogLevel) -> Self
pub fn with_log_level(self, level: LogLevel) -> Self
Set the log level for this handle
Sourcepub fn ping(&self) -> Result<PingResponse>
pub fn ping(&self) -> Result<PingResponse>
Ping the server and get version info
Sourcepub fn test_connection(&self) -> Result<String>
pub fn test_connection(&self) -> Result<String>
Test connection to the zinit server by performing a ping.
Returns Ok(version) if the connection is successful, or an error
with a descriptive message if the connection fails.
This method is useful for explicitly verifying the connection
after creating a handle with new_unchecked().
§Examples
use zinit::ZinitHandle;
let handle = ZinitHandle::new_unchecked()?;
let version = handle.test_connection()?;
println!("Connected to zinit server version: {}", version);Sourcepub fn prepare_restart(&self) -> Result<PrepareRestartResult>
pub fn prepare_restart(&self) -> Result<PrepareRestartResult>
Prepare for hot restart by saving state to disk
Sourcepub fn service_set(&self, config: ServiceConfig) -> Result<AddServiceResult>
pub fn service_set(&self, config: ServiceConfig) -> Result<AddServiceResult>
Create or update a service (always persisted)
Sourcepub fn service_get(&self, name: &str) -> Result<ServiceConfig>
pub fn service_get(&self, name: &str) -> Result<ServiceConfig>
Get service configuration
Sourcepub fn service_delete(&self, name: &str) -> Result<()>
pub fn service_delete(&self, name: &str) -> Result<()>
Delete a service (stop and remove)
Sourcepub fn list_full(&self) -> Result<Vec<ServiceInfo>>
pub fn list_full(&self) -> Result<Vec<ServiceInfo>>
List all services with state information
Sourcepub fn status(&self, name: &str) -> Result<ServiceStatus>
pub fn status(&self, name: &str) -> Result<ServiceStatus>
Get service status (simplified)
Sourcepub fn status_full(&self, name: &str) -> Result<ServiceStatusFull>
pub fn status_full(&self, name: &str) -> Result<ServiceStatusFull>
Get detailed service status with dependencies and uptime
Sourcepub fn stats(&self, name: &str) -> Result<ServiceStats>
pub fn stats(&self, name: &str) -> Result<ServiceStats>
Get CPU and memory statistics for a service
Sourcepub fn children(&self, name: &str) -> Result<ChildrenResponse>
pub fn children(&self, name: &str) -> Result<ChildrenResponse>
Get child processes for a service
Sourcepub fn is_running(&self, name: &str) -> Result<bool>
pub fn is_running(&self, name: &str) -> Result<bool>
Check if a service is currently running
Sourcepub fn why(&self, name: &str) -> Result<WhyBlocked>
pub fn why(&self, name: &str) -> Result<WhyBlocked>
Get information about why a service is blocked
Sourcepub fn logs(
&self,
name: Option<&str>,
lines: Option<usize>,
) -> Result<Vec<String>>
pub fn logs( &self, name: Option<&str>, lines: Option<usize>, ) -> Result<Vec<String>>
Get logs (simplified, returns strings)
Sourcepub fn logs_tail(
&self,
name: Option<&str>,
lines: Option<usize>,
) -> Result<Vec<LogLine>>
pub fn logs_tail( &self, name: Option<&str>, lines: Option<usize>, ) -> Result<Vec<LogLine>>
Get structured log entries
Sourcepub fn logs_filter(
&self,
name: Option<&str>,
stream: Option<&str>,
since: Option<u64>,
lines: Option<usize>,
) -> Result<Vec<LogLine>>
pub fn logs_filter( &self, name: Option<&str>, stream: Option<&str>, since: Option<u64>, lines: Option<usize>, ) -> Result<Vec<LogLine>>
Get filtered log entries
Sourcepub fn debug_state(&self) -> Result<String>
pub fn debug_state(&self) -> Result<String>
Get full supervisor state for debugging
Sourcepub fn debug_process_tree(&self, name: &str) -> Result<String>
pub fn debug_process_tree(&self, name: &str) -> Result<String>
Get process tree for a service
Sourcepub fn xinet_set(&self, config: XinetConfig) -> Result<()>
pub fn xinet_set(&self, config: XinetConfig) -> Result<()>
Create or update an xinet proxy
Sourcepub fn xinet_delete(&self, name: &str) -> Result<()>
pub fn xinet_delete(&self, name: &str) -> Result<()>
Delete an xinet proxy
Sourcepub fn xinet_list(&self) -> Result<Vec<String>>
pub fn xinet_list(&self) -> Result<Vec<String>>
List all xinet proxy names
Sourcepub fn xinet_status(&self, name: &str) -> Result<XinetStatus>
pub fn xinet_status(&self, name: &str) -> Result<XinetStatus>
Get xinet proxy status (simplified)
Sourcepub fn xinet_status_all(&self) -> Result<Vec<XinetStatusFull>>
pub fn xinet_status_all(&self) -> Result<Vec<XinetStatusFull>>
Get status of all xinet proxies
Trait Implementations§
Source§impl Clone for ZinitHandle
impl Clone for ZinitHandle
Source§fn clone(&self) -> ZinitHandle
fn clone(&self) -> ZinitHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more