Skip to main content

ZinitHandle

Struct ZinitHandle 

Source
pub struct ZinitHandle { /* private fields */ }
Expand description

Synchronous handle for Rhai functions to use

Implementations§

Source§

impl ZinitHandle

Source

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
Source

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.

Source

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
Source

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.

Source

pub fn with_client(client: ZinitClient) -> Result<Self>

Create a new handle with a specific client

Source

pub fn with_log_level(self, level: LogLevel) -> Self

Set the log level for this handle

Source

pub fn discover(&self) -> Result<Value>

Returns the OpenRPC specification

Source

pub fn ping(&self) -> Result<PingResponse>

Ping the server and get version info

Source

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);
Source

pub fn shutdown(&self) -> Result<()>

Request daemon shutdown

Source

pub fn reboot(&self) -> Result<()>

Reboot the system (Linux only, requires PID 1)

Source

pub fn prepare_restart(&self) -> Result<PrepareRestartResult>

Prepare for hot restart by saving state to disk

Source

pub fn service_set(&self, config: ServiceConfig) -> Result<AddServiceResult>

Create or update a service (always persisted)

Source

pub fn service_get(&self, name: &str) -> Result<ServiceConfig>

Get service configuration

Source

pub fn service_delete(&self, name: &str) -> Result<()>

Delete a service (stop and remove)

Source

pub fn list(&self) -> Result<Vec<String>>

List all services

Source

pub fn list_full(&self) -> Result<Vec<ServiceInfo>>

List all services with state information

Source

pub fn start(&self, name: &str) -> Result<()>

Start a service

Source

pub fn stop(&self, name: &str) -> Result<()>

Stop a service

Source

pub fn restart(&self, name: &str) -> Result<()>

Restart a service

Source

pub fn kill(&self, name: &str, signal: Option<&str>) -> Result<()>

Send a signal to a service

Source

pub fn status(&self, name: &str) -> Result<ServiceStatus>

Get service status (simplified)

Source

pub fn status_full(&self, name: &str) -> Result<ServiceStatusFull>

Get detailed service status with dependencies and uptime

Source

pub fn stats(&self, name: &str) -> Result<ServiceStats>

Get CPU and memory statistics for a service

Source

pub fn children(&self, name: &str) -> Result<ChildrenResponse>

Get child processes for a service

Source

pub fn is_running(&self, name: &str) -> Result<bool>

Check if a service is currently running

Source

pub fn why(&self, name: &str) -> Result<WhyBlocked>

Get information about why a service is blocked

Source

pub fn tree(&self) -> Result<String>

Get the dependency tree as ASCII art

Source

pub fn logs( &self, name: Option<&str>, lines: Option<usize>, ) -> Result<Vec<String>>

Get logs (simplified, returns strings)

Source

pub fn logs_tail( &self, name: Option<&str>, lines: Option<usize>, ) -> Result<Vec<LogLine>>

Get structured log entries

Source

pub fn logs_filter( &self, name: Option<&str>, stream: Option<&str>, since: Option<u64>, lines: Option<usize>, ) -> Result<Vec<LogLine>>

Get filtered log entries

Source

pub fn debug_state(&self) -> Result<String>

Get full supervisor state for debugging

Source

pub fn debug_process_tree(&self, name: &str) -> Result<String>

Get process tree for a service

Source

pub fn xinet_set(&self, config: XinetConfig) -> Result<()>

Create or update an xinet proxy

Source

pub fn xinet_delete(&self, name: &str) -> Result<()>

Delete an xinet proxy

Source

pub fn xinet_list(&self) -> Result<Vec<String>>

List all xinet proxy names

Source

pub fn xinet_status(&self, name: &str) -> Result<XinetStatus>

Get xinet proxy status (simplified)

Source

pub fn xinet_status_all(&self) -> Result<Vec<XinetStatusFull>>

Get status of all xinet proxies

Trait Implementations§

Source§

impl Clone for ZinitHandle

Source§

fn clone(&self) -> ZinitHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more