Live Inbox
Shows how to use live() for materialized row subscriptions — the same pattern used by TypeScript and Dart clients.
Source: link/sdks/rust/examples/live-inbox/
What it does
- Creates a temporary inbox table
- Opens a WebSocket and starts a
live()subscription - Receives the initial (empty) row set
- Inserts a message via SQL
- Receives the updated row set with the new message
- Cleans up the table
Run it
Expected output:
Key API pieces
| Piece | Role |
|---|---|
client.connect() | Opens the shared WebSocket before subscriptions |
SubscriptionConfig | Names the subscription and sets the live SQL |
SubscriptionOptions::with_last_rows(20) | Rewinds up to 20 recent rows on connect |
LiveRowsConfig { limit: Some(20), .. } | Caps the materialized row set the client keeps |
live.next() | Yields the next LiveRowsEvent::Rows batch |
Live SQL must stay in supported form: SELECT ... FROM ... WHERE ... (no ORDER BY or LIMIT in the subscription SQL).
Core pattern
Next
- Topic Consumer
- Realtime Subscriptions
- Realtime Ops Feed — same pattern in TypeScript
Last updated on