Client SDKsRustReference
Events
Event, EventReceive, and streaming types for fire-and-forget pub/sub
Event
Outbound fire-and-forget event message. Events are delivered to all active subscribers and then discarded.
| 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 = Event::builder()
.channel("notifications")
.body(b"hello world".to_vec())
.metadata("content-type:text/plain")
.add_tag("source", "sensor-1")
.build();EventReceive
Received from a subscription callback.
| Field | Type | Description |
|---|---|---|
id | String | Server-assigned event identifier |
channel | String | Channel the event was published to |
metadata | String | Publisher metadata |
body | Vec<u8> | Message payload |
timestamp | i64 | Server timestamp (Unix nanoseconds) |
sequence | u64 | Monotonic sequence number within the channel |
tags | HashMap<String, String> | Publisher-attached tags |
Client Methods
send_event
Sends a single fire-and-forget event.
client.send_event(event).await?;publish_event
Convenience method with minimal parameters.
client.publish_event("notifications", b"alert".to_vec(), None, None).await?;subscribe_to_events
Subscribes to events on a channel. Supports wildcards (*, >).
let sub = client.subscribe_to_events(
"events.>",
"",
|event| Box::pin(async move {
println!("Received: {}", String::from_utf8_lossy(&event.body));
}),
None,
).await?;
sub.unsubscribe().await;send_event_stream
Opens a bidirectional stream for high-throughput publishing. Returns an EventStreamHandle.
let mut handle = client.send_event_stream().await?;
handle.send(event).await?;
handle.close();EventStreamHandle
| Method | Description |
|---|---|
send(event) | Send an event through the stream |
errors() | Get a mutable reference to the error receiver |
close() | Close the stream |
Was this page helpful?