pub struct Event<D> {
pub data: D,
/* private fields */
}Expand description
Typed event with deserialized data.
Event wraps a raw crate::Event and provides typed access
to the deserialized event data. It implements Deref to
provide access to the underlying event fields (id, timestamp, version, metadata, etc.).
§Type Parameters
D: The event data type (e.g.,AccountOpened)
§Example
ⓘ
use evento::metadata::Event;
#[evento::handler]
async fn handle_deposit(
event: Event<MoneyDeposited>,
view: &mut AccountView,
) -> anyhow::Result<()> {
// Access typed data
println!("Amount: {}", event.data.amount);
// Access metadata via Deref
if let Ok(user) = event.metadata.requested_by() {
println!("By user: {}", user);
}
// Access underlying event fields via Deref
println!("Event ID: {}", event.id);
println!("Version: {}", event.version);
Ok(())
}Fields§
§data: DThe typed event data
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for Event<D>where
D: Freeze,
impl<D> RefUnwindSafe for Event<D>where
D: RefUnwindSafe,
impl<D> Send for Event<D>where
D: Send,
impl<D> Sync for Event<D>where
D: Sync,
impl<D> Unpin for Event<D>where
D: Unpin,
impl<D> UnwindSafe for Event<D>where
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more