Skip to main content

TypedEvent

Struct TypedEvent 

Source
pub struct TypedEvent<'a, E>
where E: Event,
{ /* private fields */ }
Expand description

A typed view over an emitted event, combining topic access with a pre-decoded payload.

Implementations§

Source§

impl<'a, E> TypedEvent<'a, E>
where E: Event,

Source

pub fn new(raw: &'a TxEmittedEvent) -> TypedEvent<'a, E>

Decode a raw event into a typed view.

When E declares a static topic-0 discriminant (via Event::signature), the raw event’s topic 0 is verified against it first, so a payload that merely shares a shape with E cannot be silently mistyped as E. Panics on a discriminant mismatch, a topic count differing from Event::num_topics, or payload decode failure.

Source

pub fn try_new(raw: &'a TxEmittedEvent) -> Option<TypedEvent<'a, E>>

Non-panicking twin of new: Some only if the event is well-formed, its topic 0 matches E’s declared discriminant (when one exists), its topic count matches Event::num_topics, and its payload decodes as E::Payload. The probe for scanning event streams that contain foreign events.

Source

pub fn payload(&self) -> &<E as Event>::Payload<'a>

The decoded payload.

Source

pub fn topic(&self, index: u32) -> Option<&'a [u8; 32]>

Get topic at the given index.

Source

pub fn num_topics(&self) -> u32

Number of topics.

Source

pub fn raw(&self) -> &EmittedEvent<'a>

Access the underlying untyped emitted event.

Auto Trait Implementations§

§

impl<'a, E> Freeze for TypedEvent<'a, E>
where <E as Event>::Payload<'a>: Freeze,

§

impl<'a, E> RefUnwindSafe for TypedEvent<'a, E>
where <E as Event>::Payload<'a>: RefUnwindSafe,

§

impl<'a, E> Send for TypedEvent<'a, E>
where <E as Event>::Payload<'a>: Send,

§

impl<'a, E> Sync for TypedEvent<'a, E>
where <E as Event>::Payload<'a>: Sync,

§

impl<'a, E> Unpin for TypedEvent<'a, E>
where <E as Event>::Payload<'a>: Unpin,

§

impl<'a, E> UnsafeUnpin for TypedEvent<'a, E>
where <E as Event>::Payload<'a>: UnsafeUnpin,

§

impl<'a, E> UnwindSafe for TypedEvent<'a, E>
where <E as Event>::Payload<'a>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StaticIfNoAlloc for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.