Client SDKsRustReference
Events Store
EventStore, replay types, and persistent pub/sub operations
EventStore
Outbound persistent event message. Unlike Event, store messages are persisted and can be replayed.
| Field | Type | Description |
|---|---|---|
id | String | Message ID (auto-generated UUID v4 when empty) |
channel | String | Target channel name (required) |
metadata | String | Optional UTF-8 metadata |
body | Vec<u8> | Message payload bytes |
client_id | String | Sender identity override |
tags | HashMap<String, String> | Arbitrary key-value pairs |
Builder
let event = EventStore::builder()
.channel("orders.created")
.body(b"order-data".to_vec())
.add_tag("priority", "high")
.build();EventStoreResult
Returned by send_event_store.
| Field | Type | Description |
|---|---|---|
id | String | Server-assigned event identifier |
sent | bool | Whether the server persisted the event |
error | String | Server error message when sent is false |
EventStoreReceive
Received from a subscription callback.
| Field | Type | Description |
|---|---|---|
id | String | Server-assigned event identifier |
sequence | u64 | Monotonic sequence number |
timestamp | i64 | Server timestamp (Unix nanoseconds) |
channel | String | Channel the event was published to |
metadata | String | Publisher metadata |
body | Vec<u8> | Message payload |
tags | HashMap<String, String> | Publisher-attached tags |
EventsStoreSubscription
Specifies where a subscription should begin reading.
| Variant | Description |
|---|---|
StartNewOnly | Only events published after subscription |
StartFromFirst | Replay from the first stored event |
StartFromLast | Start from the most recent event |
StartAtSequence(u64) | Start at a specific sequence number |
StartAtTime(SystemTime) | Start at a specific wall-clock time |
StartAtTimeDelta(Duration) | Start from now - delta (server interprets in seconds) |
Client Methods
send_event_store
let result = client.send_event_store(event).await?;
println!("Stored event ID: {}", result.id);subscribe_to_events_store
let sub = client.subscribe_to_events_store(
"orders.created",
"",
EventsStoreSubscription::StartFromFirst,
|event| Box::pin(async move {
println!("Seq {}: {}", event.sequence, String::from_utf8_lossy(&event.body));
}),
None,
).await?;send_event_store_stream
Opens a bidirectional stream. Returns an EventStoreStreamHandle.
let mut handle = client.send_event_store_stream().await?;
handle.send(event).await?;
handle.close();Was this page helpful?