diff --git a/README.md b/README.md index b8c371f..2718432 100644 --- a/README.md +++ b/README.md @@ -398,7 +398,7 @@ 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 @@ -406,26 +406,40 @@ let result := client.list_subjects("/books"); 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: