Struct ethcontract::contract::EventBuilder

source ·
pub struct EventBuilder<T: Transport, E: Tokenize> {
    pub filter: LogFilterBuilder<T>,
    pub topics: RawTopicFilter,
    /* private fields */
}
Expand description

A builder for creating a filtered stream of contract events that are

Fields§

§filter: LogFilterBuilder<T>

The web3 filter builder used for creating a log filter.

§topics: RawTopicFilter

The topic filters that are encoded based on the event ABI.

Implementations§

source§

impl<T: Transport, E: Tokenize> EventBuilder<T, E>

source

pub fn new(web3: Web3<T>, event: AbiEvent, address: Address) -> Self

Creates a new event builder from a web3 provider and a contract event and address.

source

pub fn from_block(self, block: BlockNumber) -> Self

Sets the starting block from which to stream logs for.

If left unset defaults to the latest block.

source

pub fn to_block(self, block: BlockNumber) -> Self

Sets the last block from which to stream logs for.

If left unset defaults to the streaming until the end of days.

source

pub fn topic0<P>(self, topic: Topic<P>) -> Self
where P: Tokenize,

Adds a filter for the first indexed topic.

This corresponds to the first indexed property, which for anonymous events corresponds to topic[0] in the log, and for named events is actually topic[1].

source

pub fn topic1<P>(self, topic: Topic<P>) -> Self
where P: Tokenize,

Adds a filter for the second indexed topic.

source

pub fn topic2<P>(self, topic: Topic<P>) -> Self
where P: Tokenize,

Adds a filter for the third indexed topic.

source

pub fn limit(self, value: usize) -> Self

Limit the number of events that can be retrieved by this filter.

Note that this parameter is non-standard.

source

pub fn poll_interval(self, value: Duration) -> Self

The polling interval. This is used as the interval between consecutive eth_getFilterChanges calls to get filter updates.

source

pub fn into_inner(self) -> Result<(AbiEvent, LogFilterBuilder<T>), EventError>

Returns a LogFilterBuilder instance for the current builder.

source

pub async fn query(self) -> Result<Vec<Event<E>>, EventError>

Returns a future that resolves with a collection of all existing logs matching the builder parameters.

source

pub fn stream(self) -> impl Stream<Item = Result<StreamEvent<E>, EventError>>

Creates an event stream from the current event builder that emits new events.

Trait Implementations§

source§

impl<T: Debug + Transport, E: Debug + Tokenize> Debug for EventBuilder<T, E>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, E> Freeze for EventBuilder<T, E>
where T: Freeze,

§

impl<T, E> RefUnwindSafe for EventBuilder<T, E>

§

impl<T, E> Send for EventBuilder<T, E>
where E: Send, T: Send,

§

impl<T, E> Sync for EventBuilder<T, E>
where E: Sync, T: Sync,

§

impl<T, E> Unpin for EventBuilder<T, E>
where E: Unpin, T: Unpin,

§

impl<T, E> UnwindSafe for EventBuilder<T, E>
where E: UnwindSafe, T: 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more