AeroStream Rust Client SDK (aerostream-client)
The official high-performance, production-grade Rust client SDK for the AeroStream native binary protocol (0xAE 0x01).
Features
- Native Binary Protocol: Fast zero-copy framing (
0xAE 0x01), Big-Endian wire layout. - Asynchronous & Non-Blocking: Built on Tokio runtime (
TCP_NODELAY, custom framing). - Cancellation Safety: Defused operation guards protect connection streams from corrupted state during timeout or cancellation.
- Resilient Producer: Configurable exponential backoff retry policy with randomized jitter.
- Flexible Consumer: Multi-entry long-polling fetch (
Command 4) and continuous asyncStreamconsumption. - Connection Management: High-level
AeroClientwith connection pooling and resource reuse. - TLS Support: Optional encrypted transport via
tokio-rustls.
Installation
Add to your Cargo.toml:
[]
= { = "../rust" }
Or with TLS enabled:
[]
= { = "../rust", = ["tls"] }
Quick Start
Producer
use ;
async
Consumer (Batch & Continuous Stream)
use ;
use StreamExt;
async
Protocol Wire Format Reference
- Header (7B):
[magic: 0xAE, 0x01 (2B)][cmd: u8 (1B)][body_len: u32 BE (4B)] - Command 0 (Auth):
- Request:
[token: UTF-8] - Response:
[0xAE, 0x01, status: u8](0 = OK, 3 = Auth Failed)
- Request:
- Command 1 (Produce):
- Request:
[topic_len: u16 BE][topic: UTF-8][partition: u32 BE][payload_len: u32 BE][payload: raw bytes] - Response:
[0xAE, 0x01, status: u8][offset: u64 BE](status 0 = OK, 45 = OutOfOrder)
- Request:
- Command 2 (Consumer Fetch):
- Request:
[topic_len: u16 BE][topic: UTF-8][partition: u32 BE][start_offset: u64 BE][max_bytes: u32 BE] - Response:
[0xAE, 0x01, status: u8](1 = Empty, 2 = Data followed by[len: u32 BE][stream])
- Request:
- Command 4 (Multi-Entry Fetch):
- Request:
[topic_len: u16 BE][topic: UTF-8][partition: u32 BE][start_offset: u64 BE][max_bytes: u32 BE][max_wait_ms: u32 BE] - Response:
[0xAE, 0x01, status: u8](1 = Empty, 2 = Data followed by[count: u32 BE][(offset: u64, len: u32)...][payloads])
- Request: