LatZero Rust Client
Async Rust client for latzero-server. It implements the same newline-delimited
JSON TCP protocol as the Python server-mode LatZero client.
The Python client's standalone shared-memory implementation is intentionally
out of scope. Rust and Python applications interoperate through
latzero-server.
Features
- Tokio-based TCP transport with
hello, pool join/switch/leave, request IDs, timeouts, and typed server errors - Concurrent request correlation, including two-stage
ackandapp_resultcalls - JSON buffers, TTL, persistence, listing, client-derived batches and scans
- Buffer subscriptions and presence/update event streams
- Targeted and broadcast events, app RPC, third-party response routing
- Process registration, direct/short-name calls, broadcast, discovery, worker metrics, and server-directed concurrency scaling
- Namespaced buffers and event emitters
- Cancellation-safe frame writer and automatic socket cleanup when the final client handle is dropped
Install
[]
= { = "../rust-client" }
= "1"
= { = "1", = ["macros", "rt-multi-thread"] }
Start the server first:
latzero-server --headless
Buffers
use Duration;
use Client;
use ;
async
get returns Option<T>, so a missing buffer is distinct from a present JSON
null when T can represent null, such as serde_json::Value.
Events And RPC
Handlers receive a JSON object and may return any serializable value.
use Client;
use ;
async
Use Client::events() for unsolicited presence_update, buffer_update,
emitted events, third-party app results, scaling commands, disconnects, and
unknown forward-compatible protocol messages. CallOutcome::Routed preserves
the request ID when response_to sends a result to another client.
Processes
use ;
use ;
async
Calling the canonical process_id works with all released server revisions;
current servers additionally accept a short process name and select a worker
using round-robin routing.
WorkerKind values are sent as protocol metadata for compatibility. Rust
handlers execute as asynchronous Tokio tasks; min_workers and max_workers
control local concurrent handler execution. Selecting Process does not move a
Rust closure into an operating-system child process.
Compatibility
The client covers every message currently dispatched by latzero-server:
hello, join_pool, switch_pool, leave_pool,
set_buffer, get_buffer, delete_buffer, list_buffers, list_clients,
subscribe_buffer, unsubscribe_buffer,
emit_event, call_app, app_result,
register_process, unregister_process, call_process, broadcast_process,
list_processes, worker_metrics
The server protocol currently has no version negotiation, TLS, reconnection,
or resumable sessions. A closed connection fails pending requests; construct a
new Client to reconnect and re-register handlers/processes.
Verification
cargo fmt --all -- --check
cargo test --all-targets
cargo clippy --all-targets -- -D warnings
cargo doc --no-deps