lirays 0.1.2

Rust client for LiRAYS SCADA over WebSocket + Protobuf
Documentation
/// Configuration used to create an integer variable in the namespace.
///
/// # Example
/// ```rust
/// use lirays::IntegerVar;
///
/// let var = IntegerVar {
///     name: "motor_rpm".into(),
///     unit: Some("rpm".into()),
///     min: Some(0.0),
///     max: Some(3600.0),
/// };
/// assert_eq!(var.name, "motor_rpm");
/// ```
#[derive(Clone, Debug)]
pub struct IntegerVar {
    /// Variable name relative to its parent folder.
    pub name: String,
    /// Optional engineering unit (for example, `rpm` or `bar`).
    pub unit: Option<String>,
    /// Optional minimum allowed value.
    pub min: Option<f64>,
    /// Optional maximum allowed value.
    pub max: Option<f64>,
}

/// Configuration used to create a float variable in the namespace.
///
/// # Example
/// ```rust
/// use lirays::FloatVar;
///
/// let var = FloatVar {
///     name: "tank_level".into(),
///     unit: Some("%".into()),
///     min: Some(0.0),
///     max: Some(100.0),
/// };
/// assert_eq!(var.unit.as_deref(), Some("%"));
/// ```
#[derive(Clone, Debug)]
pub struct FloatVar {
    /// Variable name relative to its parent folder.
    pub name: String,
    /// Optional engineering unit (for example, `rpm` or `bar`).
    pub unit: Option<String>,
    /// Optional minimum allowed value.
    pub min: Option<f64>,
    /// Optional maximum allowed value.
    pub max: Option<f64>,
}

/// Configuration used to create a text variable in the namespace.
///
/// # Example
/// ```rust
/// use lirays::TextVar;
///
/// let var = TextVar {
///     name: "mode".into(),
///     unit: None,
///     options: vec!["AUTO".into(), "MAN".into(), "OFF".into()],
///     max_len: Some(8),
/// };
/// assert_eq!(var.options.len(), 3);
/// ```
#[derive(Clone, Debug)]
pub struct TextVar {
    /// Variable name relative to its parent folder.
    pub name: String,
    /// Optional engineering unit or semantic label.
    pub unit: Option<String>,
    /// Optional list of allowed values.
    pub options: Vec<String>,
    /// Optional maximum character length.
    pub max_len: Option<u64>,
}

/// Configuration used to create a boolean variable in the namespace.
///
/// # Example
/// ```rust
/// use lirays::BooleanVar;
///
/// let var = BooleanVar {
///     name: "pump_enabled".into(),
///     unit: None,
/// };
/// assert_eq!(var.name, "pump_enabled");
/// ```
#[derive(Clone, Debug)]
pub struct BooleanVar {
    /// Variable name relative to its parent folder.
    pub name: String,
    /// Optional engineering unit or semantic label.
    pub unit: Option<String>,
}

/// Partial metadata update payload for an existing variable.
///
/// # Example
/// ```rust
/// use lirays::VariableMetadataPatch;
///
/// let patch = VariableMetadataPatch {
///     unit: Some("psi".into()),
///     min: Some(1.0),
///     max: Some(20.0),
///     options: vec![],
///     max_len: None,
/// };
/// assert_eq!(patch.unit.as_deref(), Some("psi"));
/// ```
#[derive(Clone, Debug, Default)]
pub struct VariableMetadataPatch {
    /// New engineering unit. `None` keeps current server value.
    pub unit: Option<String>,
    /// New minimum value. `None` keeps current server value.
    pub min: Option<f64>,
    /// New maximum value. `None` keeps current server value.
    pub max: Option<f64>,
    /// New list of allowed text values.
    pub options: Vec<String>,
    /// New maximum text length.
    pub max_len: Option<u64>,
}