zinit 0.3.9

Process supervisor with dependency management
Documentation
//! Client-facing types for zinit RPC API
//!
//! These types are used by all client implementations (CLI, TUI, Rhai) for
//! communication with the zinit server. They are serde-compatible for JSON-RPC.

use serde::{Deserialize, Serialize};

use super::{SocketAddr, State};

/// Full service status with additional details
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServiceStatusFull {
    pub name: String,
    pub state: State,
    pub pid: u32,
    pub uptime_ms: u64,
    pub restart_count: u32,
    pub last_start: u64,
    pub last_stop: u64,
    pub cpu_percent: f32,
    pub memory_bytes: u64,
    pub blocked_by: Vec<String>,
}

/// Extended xinet proxy definition with additional fields
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct XinetDef {
    pub name: String,
    pub listen: Vec<SocketAddr>,
    pub backend: SocketAddr,
    pub service: String,
    pub connect_timeout: u64,
    pub idle_timeout: u64,
    pub single_connection: bool,
    pub description: Option<String>,
}

/// Extended xinet status with metrics
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct XinetStatusFull {
    pub name: String,
    pub listen: Vec<String>,
    pub backend: String,
    pub service: String,
    pub running: bool,
    pub total_connections: u64,
    pub active_connections: usize,
    pub bytes_to_backend: u64,
    pub bytes_from_backend: u64,
    pub connect_timeout: u64,
    pub idle_timeout: u64,
}

/// Debug output structure
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DebugOutput {
    pub timestamp: u64,
    pub level: String,
    pub message: String,
}

/// Logging levels for client operations (0-3)
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LogLevel {
    Silent = 0,
    Minimal = 1,
    Normal = 2,
    Verbose = 3,
}

impl From<u32> for LogLevel {
    fn from(n: u32) -> Self {
        match n {
            0 => LogLevel::Silent,
            1 => LogLevel::Minimal,
            3 => LogLevel::Verbose,
            _ => LogLevel::Normal,
        }
    }
}

// Re-export all SDK types for convenience
pub use super::{
    ChildProcessInfo as ChildProcessInfo_, ChildrenResponse as ChildrenResponse_,
    DependencyDef as DependencyDef_, DependencyInfo as DependencyInfo_,
    FailureReason as FailureReason_, HealthCommon as HealthCommon_, HealthDef as HealthDef_,
    LifecycleDef as LifecycleDef_, LogLine as LogLine_, LoggingDef as LoggingDef_,
    PingResponse as PingResponse_, PrepareRestartResult as PrepareRestartResult_,
    RestartPolicy as RestartPolicy_, ServiceClass as ServiceClass_,
    ServiceConfig as ServiceConfig_, ServiceDef as ServiceDef_, ServiceInfo as ServiceInfo_,
    ServiceStats as ServiceStats_, ServiceStatus as ServiceStatus_, SocketAddr as SocketAddr_,
    State as State_, Status as Status_, TreeResponse as TreeResponse_, WhyBlocked as WhyBlocked_,
    XinetConfig as XinetConfig_, XinetStatus as XinetStatus_,
};