Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,34 +398,48 @@ match result {
If you only want to list subjects within a specific branch, provide the desired base subject instead:

```rust
let result := client.list_subjects("/books");
let result = client.list_subjects("/books");
```

### Listing Event Types

To list all event types, call the `list_event_types` function. The function returns a stream from which you can retrieve one event type at a time:

```rust
let result := client.list_event_types().await;
let result = client.list_event_types().await;
match result {
Ok(event_types) => // ...
Err(err) => // ...
}
```

### Listing a Specific Event Types
### Listing a Specific Event Type

To list a specific event type, call the `read_event_type` function. The function returns the detailed event type, which includes the schema:

```rust
let event_type_name = "io.eventsourcingdb.library.book-acquired";
let result := client.read_event_type(event_type_name).await;
let result = client.read_event_type(event_type_name).await;
match result {
Ok(event_type) => // ...
Err(err) => // ...
}
```

### Verifying an Event's Hash

To verify the integrity of an event, call the `verify_hash` function on the event instance. This recomputes the event's hash locally and compares it to the hash stored in the event. If the hashes differ, the function returns an error:

```rust
let result = event.verify_hash();
match result {
Ok(()) => // ...
Err(err) => // ...
}
```

*Note that this only verifies the hash. If you also want to verify the signature, you can skip this step and call `verify_signature` directly, which performs a hash verification internally.*

### Using Testcontainers

Call the `Container::start_default()` function, get a client, and run your test code:
Expand Down