lirays 0.1.1

Rust client for LiRAYS-SCADA over WebSocket + Protobuf
Documentation

lirays

Rust client for LiRAYS-SCADA WebSocket + protobuf protocol.

Install

Cargo.toml:

[dependencies]
lirays = "0.1"

Authentication model

This client supports authentication using a PAT token generated by lirays (generate-admin-token / generate-operator-token).

The PAT is sent as:

  • Authorization: Bearer <pat_token> during WebSocket upgrade.

Connection methods

Use the method that matches your server auth configuration:

  • Client::connect(host, port, tls) for unauthenticated servers.
  • Client::connect_with_pat(host, port, tls, pat_token) for authenticated servers (sends Authorization: Bearer <pat_token>).
  • Client::connect_with_options(ConnectionOptions) when you want explicit control over all connection fields.

Unauthenticated

use lirays::Client;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Client::connect("127.0.0.1", 8245, false).await?;
    client.disconnect().await?;
    Ok(())
}

All command APIs accept a timeout_ms parameter and return ClientError::Timeout when the response is not received in time.

Authenticated (PAT)

use lirays::Client;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Client::connect_with_pat("127.0.0.1", 8245, false, "pat_xxx.yyy").await?;
    client.disconnect().await?;
    Ok(())
}

Quick start

use lirays::Client;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Client::connect_with_pat(
        "127.0.0.1",
        8245,
        false, // tls
        "pat_xxx.yyy",
    )
    .await?;

    let (_folders, vars) = client.list(Some("/".into()), 5_000).await?;
    println!("vars: {}", vars.len());

    client.disconnect().await?;
    Ok(())
}

Main capabilities

  • Namespace CRUD: create folders, create variables, list, delete.
  • Typed value writes/reads: integer, float, text, boolean.
  • Metadata updates via edit_variable_metadata.
  • Bulk namespace creation from JSON schema (create_bulk_from_json).
  • Realtime subscriptions (subscribe_var_values).

Development

cargo check --manifest-path clients/rust-client/Cargo.toml

Run demos:

cargo run --manifest-path clients/rust-client/Cargo.toml --bin demo -- --demo all --auth true --pat-token "pat_xxx.yyy"