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§
- Aimx
Config - Configuration for AimX remote access
- Build
Reply - The
buildpart ofInstanceInfoReply. - Error
Object - Error object in response
- Event
- Event message from server (subscription push)
- Hello
Message - Client hello message
- Inbound
Keys Info - A record’s key table. Key names are not listed;
inbound_key_nameresolves one. - Instance
Identity Reply - The
instancepart ofInstanceInfoReply. - Instance
Info Reply - Reply of
instance.info(3.1): which build and which instance this is. - Post
Link Chunk - Reply of
instance.post_link(3.1): one chunk of the written post-link bytes. Clients read from offset 0 until they holdtotalbytes. - Query
Handler Params - Parameters for the type-erased query handler.
- Query
Record - One row of a
record.queryresult — the canonical shape every transport shares. - Record
Metadata - Metadata about a registered record type
- Request
- Request message from client
- Welcome
Message - Server welcome message
Enums§
- Post
Link Error - Why
instance.post_linkhas no chunk to send. - Post
Link Reply - State of the post-link region.
- Remote
Error - Error type for remote access operations
- Response
- Response message from server
- Security
Policy - Security policy for remote access
Constants§
- INSTANCE_
INFO_ REPLY_ MAX - Upper bound on an
instance.inforeply, 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_linkreply carries; the reply’sdatais twice as many hex digits. - PROTOCOL_
VERSION - Version of the AimX wire protocol spoken by this crate.
- QUERY_
ALL_ PATTERN - The pattern a
record.querywith nonameresolves to: every record, at every depth. - VERSION_
PARAM - Query-parameter name a WebSocket client uses to declare its
PROTOCOL_VERSIONat the HTTP upgrade. The socket transports gate the version inside thehellohandshake, but a browser cannot set custom headers on the WebSocket handshake and the WS server runsreads_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. Seews_url_with_version.
Functions§
- instance_
info_ reply - The
instance.inforeply fordb, as JSON bytes. - post_
link_ chunk_ reply - The
instance.post_linkreply fordband the request’sparams, 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.viennaorsensors/temp/vienna), and both yieldvienna. Servers report this as a record’sentity, which identifies the node only where the leaf is the node:station.17.temperatureyieldstemperature, not17. - version_
compatible - Whether a peer advertising
their_versionis wire-compatible with this crate’sPROTOCOL_VERSION. - ws_
url_ with_ version - Append this crate’s
PROTOCOL_VERSIONas theVERSION_PARAMquery parameter to a WebSocket upgradeurl, joining with&ifurlalready 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 theNAME=VALUEcontract here means the reader (the server) and the writers (the dialers) never drift.
Type Aliases§
- Query
Handler Fn - Type-erased query handler registered by
aimdb-persistencevia Extensions. - Remote
Result - Result type for remote operations