Skip to main content

Module remote

Module remote 

Source
Expand description

Remote access subsystem for AimDB (AimX protocol)

Provides introspection and management APIs over Unix domain sockets, enabling external tools (CLI, dashboards, MCP adapters) to interact with running AimDB instances.

§Protocol

AimX uses NDJSON (newline-delimited JSON) tagged frames over a session transport (Unix domain sockets via aimdb-uds-connector, serial via aimdb-serial-connector). The envelope codec lives in session::aimx (feature connector-session). Compatibility is by major version — see PROTOCOL_VERSION and version_compatible.

§Security

  • Read-only by default: No writes unless explicitly enabled
  • UDS permissions: Primary security mechanism (file permissions)
  • Optional auth tokens: Additional authentication layer
  • Per-record write permissions: Explicit opt-in required

§Usage

Remote access is registered like any other connector — via with_connector using aimdb_uds_connector::UdsServer (this replaced the former AimDbBuilder::with_remote_access(config)). Illustrative (not compiled: the connector lives in a downstream crate aimdb-core cannot depend on):

ⓘ
use aimdb_core::remote::{AimxConfig, SecurityPolicy};
use aimdb_uds_connector::UdsServer;

let config = AimxConfig::uds_default()
    .socket_path("/var/run/aimdb/aimdb.sock")
    .security_policy(SecurityPolicy::ReadOnly)
    .max_connections(16)
    .max_subs_per_connection(32);

let (db, runner) = AimDbBuilder::new()
    .runtime(tokio_adapter)
    .with_connector(UdsServer::from_config(config))
    .build()
    .await?;

Structs§

AimxConfig
Configuration for AimX remote access
BuildReply
The build part of InstanceInfoReply.
ErrorObject
Error object in response
Event
Event message from server (subscription push)
HelloMessage
Client hello message
InboundKeysInfo
A record’s key table. Key names are not listed; inbound_key_name resolves one.
InstanceIdentityReply
The instance part of InstanceInfoReply.
InstanceInfoReply
Reply of instance.info (3.1): which build and which instance this is.
PostLinkChunk
Reply of instance.post_link (3.1): one chunk of the written post-link bytes. Clients read from offset 0 until they hold total bytes.
QueryHandlerParams
Parameters for the type-erased query handler.
QueryRecord
One row of a record.query result — the canonical shape every transport shares.
RecordMetadata
Metadata about a registered record type
Request
Request message from client
WelcomeMessage
Server welcome message

Enums§

PostLinkError
Why instance.post_link has no chunk to send.
PostLinkReply
State of the post-link region.
RemoteError
Error type for remote access operations
Response
Response message from server
SecurityPolicy
Security policy for remote access

Constants§

INSTANCE_INFO_REPLY_MAX
Upper bound on an instance.info reply, in bytes of JSON: a 4 KiB payload, a 128-byte name (JSON escaping at most 6× it), a 32-byte UID as hex and the fixed fields. Every reply fits the smallest AimX frame (serial, 8 KiB).
POST_LINK_CHUNK_MAX
Most bytes of post-link data one instance.post_link reply carries; the reply’s data is twice as many hex digits.
PROTOCOL_VERSION
Version of the AimX wire protocol spoken by this crate.
QUERY_ALL_PATTERN
The pattern a record.query with no name resolves to: every record, at every depth.
VERSION_PARAM
Query-parameter name a WebSocket client uses to declare its PROTOCOL_VERSION at the HTTP upgrade. The socket transports gate the version inside the hello handshake, but a browser cannot set custom headers on the WebSocket handshake and the WS server runs reads_hello:false, so the WS upgrade carries the version in the URL instead (…/ws?v=4.0) and the server refuses an incompatible/absent one before the socket opens. See ws_url_with_version.

Functions§

instance_info_reply
The instance.info reply for db, as JSON bytes.
post_link_chunk_reply
The instance.post_link reply for db and the request’s params, as JSON bytes: one chunk of the written post-link bytes.
topic_leaf
The leaf (entity) segment of a record key — the trailing component after the last separator. Both . and / are treated as delimiters, since keys use either convention (temp.vienna or sensors/temp/vienna), and both yield vienna. Servers report this as a record’s entity, which identifies the node only where the leaf is the node: station.17.temperature yields temperature, not 17.
version_compatible
Whether a peer advertising their_version is wire-compatible with this crate’s PROTOCOL_VERSION.
ws_url_with_version
Append this crate’s PROTOCOL_VERSION as the VERSION_PARAM query parameter to a WebSocket upgrade url, joining with & if url already carries a query string and ? otherwise. Every first-party WS client dialer routes its URL through this so the server’s upgrade-time gate sees a version; keeping the NAME=VALUE contract here means the reader (the server) and the writers (the dialers) never drift.

Type Aliases§

QueryHandlerFn
Type-erased query handler registered by aimdb-persistence via Extensions.
RemoteResult
Result type for remote operations