# fluxar
> Universal asynchronous bidirectional messaging protocol for Rust.
> RPC + Streaming + PubSub in a single unified protocol.
⚠️ **This crate is under active development and not yet functional.** This is a name reservation for the upcoming Rust implementation of the FLUXAR protocol. See the [specification](https://github.com/fluxar-protocol/spec) for protocol details.
## What is FLUXAR
FLUXAR is a transport-agnostic application protocol that unifies three communication patterns — request-response (RPC), streaming, and publish-subscribe — within a single envelope format.
After a handshake, both peers are equal: either side can call methods, open streams, subscribe to topics, and publish events.
**Core design:**
- 7 message types, 7-field envelope, CBOR serialisation
- The `ref` mechanism — a single field turns any message from request into response
- Fully asynchronous — send and receive are independent, no head-of-line blocking
- Symmetric — no client/server distinction after handshake
- Transport-agnostic — WebSocket, TCP, QUIC, Unix socket
## Planned Features
- Async-first API built on Tokio
- All four transports: WebSocket, TCP, QUIC, Unix socket
- Full streaming lifecycle with state machine (IDLE → ACTIVE → CANCELLING → CLOSED)
- PubSub with three delivery guarantee modes (at-most-once, at-least-once, exactly-once)
- Session resume after connection loss
- Optional Zstd/Gzip compression
- Optional end-to-end encryption (X25519 + AES-256-GCM / ChaCha20-Poly1305)
- Capability negotiation during handshake
- IDL-based code generation for typed clients and servers
## Example (planned API)
```rust
// Server
let server = fluxar::Server::bind("0.0.0.0:9000")
.transport(fluxar::Transport::WebSocket)
.build()
.await?;
let user = db.find_user(user_id).await?;
Ok(user)
});
server.run().await?;
```
```rust
// Client
let client = fluxar::Client::connect("ws://localhost:9000")
.auth(fluxar::Auth::bearer(token))
.build()
.await?;
let user: User = client.call("users.get", &user_id).await?;
```
```rust
// Streaming
let stream = client.stream("llm.complete", &prompt).await?;
while let Some(chunk) = stream.next().await {
print!("{}", chunk?.token);
}
```
```rust
// PubSub
msg.ack().await
}).await?;
```
> **Note:** The API above is illustrative and subject to change.
## Specification
The full protocol specification is maintained at [github.com/fluxar-protocol/spec](https://github.com/fluxar-protocol/spec).
| L0: Transport | WebSocket, TCP, QUIC, Unix socket |
| L1: Framing | Message boundaries |
| L2: Wire Format | CBOR, optional compression and encryption |
| L3: Message | 7 types, envelope, ref mechanism |
| L4: Session | Handshake, auth, heartbeat, resume |
| L5: Patterns | RPC, Streaming, PubSub |
## Conformance Levels
| **FLUXAR Core** | RPC only, one transport — minimal viable implementation |
| **FLUXAR Complete** | Full streaming, PubSub, resume, compression, encryption |
## License
Apache-2.0 — see [LICENSE](LICENSE).