Skip to main content

Crate aimdb_ws_protocol

Crate aimdb_ws_protocol 

Source
Expand description

§aimdb-ws-protocol

Shared wire protocol types for the AimDB WebSocket connector ecosystem.

Used by:

  • aimdb-websocket-connector — the server side (Axum/Tokio)
  • aimdb-wasm-adapter — the browser client (WsBridge)

§Wire Protocol

All messages are JSON-encoded with a "type" discriminant tag:

§Server → Client (ServerMessage)

  • data — live record push with timestamp
  • snapshot — late-join current value
  • subscribed — subscription acknowledgement
  • error — per-operation error
  • pong — response to client ping
  • query_result — response to a client query request

§Client → Server (ClientMessage)

  • subscribe — subscribe to one or more topics (supports MQTT wildcards)
  • unsubscribe — cancel subscriptions
  • write — inbound value for a link_from("ws://…") record
  • ping — keepalive ping
  • query — query historical / persisted records

§Topic Matching

topic_matches implements MQTT-style wildcard matching (# for multi-level, * for single-level).

Structs§

QueryRecord
A single record returned in a ServerMessage::QueryResult.
TopicInfo
Metadata for a single outbound topic served by a WebSocket endpoint.

Enums§

ClientMessage
A message received from a WebSocket client.
ErrorCode
Machine-readable error codes sent in ServerMessage::Error.
ServerMessage
A message sent from the server to a connected WebSocket client.

Functions§

now_ms
Returns the current milliseconds since the Unix epoch (for ts fields).
topic_matches
Returns true if topic matches pattern.