# Events (/sdks/rust/reference/events)



## Event [#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 [#builder]

```rust title="main.rs"
let event = Event::builder()
    .channel("notifications")
    .body(b"hello world".to_vec())
    .metadata("content-type:text/plain")
    .add_tag("source", "sensor-1")
    .build();
```

## EventReceive [#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 [#client-methods]

### send\_event [#send_event]

Sends a single fire-and-forget event.

```rust title="main.rs"
client.send_event(event).await?;
```

### publish\_event [#publish_event]

Convenience method with minimal parameters.

```rust title="main.rs"
client.publish_event("notifications", b"alert".to_vec(), None, None).await?;
```

### subscribe\_to\_events [#subscribe_to_events]

Subscribes to events on a channel. Supports wildcards (`*`, `>`).

```rust title="main.rs"
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 [#send_event_stream]

Opens a bidirectional stream for high-throughput publishing. Returns an `EventStreamHandle`.

```rust title="main.rs"
let mut handle = client.send_event_stream().await?;
handle.send(event).await?;
handle.close();
```

## EventStreamHandle [#eventstreamhandle]

| Method        | Description                                   |
| ------------- | --------------------------------------------- |
| `send(event)` | Send an event through the stream              |
| `errors()`    | Get a mutable reference to the error receiver |
| `close()`     | Close the stream                              |
