Expand description
brain-db-sdk — Rust client for the Brain memory database.
Brain ships no client library; its contract is the wire protocol — a
32-byte BRN0 frame header plus CBOR payloads over TCP. This crate
re-implements that protocol independently (the protocol, not a shared
library, is the source of truth) and is verified byte-for-byte
against Brain’s vendored conformance corpus.
The wire module is the codec: the frame codec (wire::frame),
the CBOR payload codec (wire::cbor), the opcode table
(wire::opcode), and the typed payload structs (wire::types) for
the handshake and the verbs — all runtime-agnostic and verified against
the corpus.
Layered on top: transport reads/writes whole frames over an async byte
stream, mux is the multiplexed MuxConnection (a background reader
task demultiplexes responses by stream_id) — the one connection type — and
client is the high-level BrainClient built on it — every verb takes
&self, so one client serves concurrent requests. verbs holds the
ergonomic request builders, retry the backoff combinator, and pool a
fixed-size connection pool for socket-level parallelism. Transparent
reconnect and connection-pool health-checking are the remaining later work.
Re-exports§
pub use client::derive_space_id;pub use client::new_id;pub use client::Auth;pub use client::BrainClient;pub use client::ClientConfig;pub use client::ConnectionInfo;pub use client::RecallAnswer;pub use error::BrainError;pub use error::Result;pub use mux::HandshakeOutcome;pub use mux::MuxConnection;pub use mux::Subscription;pub use pool::Pool;pub use retry::with_default_retry;pub use retry::with_retry;pub use retry::RetryPolicy;pub use verbs::EncodeBuilder;pub use verbs::ForgetBuilder;pub use verbs::RecallBuilder;pub use http::BrainHttpClient;pub use http::BrainHttpError;pub use http::HttpRetryPolicy;
Modules§
- client
- The high-level client: connect, handshake, and serve the v1 + typed-graph verbs over a multiplexed connection.
- error
- Client error taxonomy.
- http
- The HTTP tier of the Brain SDK —
BrainHttpClient+ its contract types. - mux
- Multiplexed connection: many requests in flight at once over one socket.
- pool
- A fixed-size connection pool over
BrainClient. - retry
- Retry policy and a combinator that applies it to any client operation.
- transport
- Async frame transport: read and write whole BRN0 frames over a byte stream.
- verbs
- Ergonomic request builders for the v1 verbs.
- wire
- Wire-protocol layer: the 32-byte BRN0 frame codec (L1), the CBOR payload codec + trailing raw-vector section (L2), the opcode table, and the typed request/response structs the payloads decode to.