Skip to main content

Crate motorcortex_rust

Crate motorcortex_rust 

Source
Expand description

Rust client for the Motorcortex real-time control system.

Implements the wire protocol defined by motorcortex.proto over NNG + WebSocket Secure: request/reply for parameter access, publish/subscribe for real-time streaming, and the session-token dance that keeps long-lived connections alive through reverse proxies and transient server restarts.

Two frontends share one actor-style core:

  • core — async (tokio-driven). The recommended surface. Handles are Clone + Send + Sync; multiple tasks share one connection safely.
  • blocking — thin sync wrapper for scripts, tests, and code that doesn’t want a tokio runtime in main(). Same method names and semantics, just without .await.

§Example — async round-trip

use motorcortex_rust::core::Request;
use motorcortex_rust::{ConnectionOptions, Result};

let opts = ConnectionOptions::new("tests/mcx.cert.crt".into(), 5000, 5000);
let req  = Request::connect_to("wss://127.0.0.1:5568", opts).await?;
req.login("root", "secret").await?;
req.request_parameter_tree().await?;

let value: f64 = req.get_parameter("root/Control/dummyDouble").await?;
println!("{value}");

req.disconnect().await?;

See the examples/ directory for blocking, subscribe-latest, and subscribe-stream flavours, and ARCHITECTURE.md for the design rationale — actor driver, three-sink subscription model, reconnect + session-token machinery.

Re-exports§

pub use core::ConnectionState;

Modules§

blocking
Blocking façade over the async core::* types.
core
Async-first core: actor-style Request / Subscribe + their drivers.
nng_init_parameter

Structs§

ConnectionOptions
Options used to configure the connection settings.
ConsoleCmdListMsg
ConsoleCmdMsg
CreateGroupMsg
Error
ErrorList
GetParameterListMsg
GetParameterMsg
GetParameterTreeHashMsg
GetParameterTreeMsg
GetSessionTokenMsg
GroupMsg
GroupParameterInfo
GroupStatusMsg
Header
LoadMsg
LoginMsg
LogoutMsg
OverwriteParameterMsg
ParameterInfo
ParameterListMsg
ParameterMsg
ParameterOffset
ParameterTree
ParameterTreeHashMsg
ParameterTreeMsg
ReleaseParameterMsg
RemoveGroupMsg
RestoreSessionMsg
SaveMsg
SessionTokenMsg
SetParameterListMsg
SetParameterMsg
StatusMsg
TimeSpec

Enums§

DataType
ErrorLevel
LogLevel
MotorcortexError
Error type for all motorcortex-rust operations.
OffsetType
ParameterFlag
ParameterType
Permission
StatusCode
Unit
UserGroup

Traits§

GetParameterValue
Hash
Represents a trait for associating a unique, compile-time constant hash with a type.
Parameters
SetParameterValue

Functions§

get_hash
Retrieve a compile-time constant hash for a message type.
get_hash_size
Retrieve the size, in bytes, of a compile-time constant hash used in the system.
init_debug_logger
init_logger
init_threads
init_threads_with_defaults
parse_url
Split a Motorcortex URL into (req_url, sub_url).

Type Aliases§

Result
Convenience alias used throughout the library.