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: RawTopicFilterThe topic filters that are encoded based on the event ABI.
Implementations§
source§impl<T: Transport, E: Tokenize> EventBuilder<T, E>
impl<T: Transport, E: Tokenize> EventBuilder<T, E>
sourcepub fn new(web3: Web3<T>, event: AbiEvent, address: Address) -> Self
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.
sourcepub fn from_block(self, block: BlockNumber) -> Self
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.
sourcepub fn to_block(self, block: BlockNumber) -> Self
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.
sourcepub fn topic0<P>(self, topic: Topic<P>) -> Selfwhere
P: Tokenize,
pub fn topic0<P>(self, topic: Topic<P>) -> Selfwhere
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].
sourcepub fn topic1<P>(self, topic: Topic<P>) -> Selfwhere
P: Tokenize,
pub fn topic1<P>(self, topic: Topic<P>) -> Selfwhere
P: Tokenize,
Adds a filter for the second indexed topic.
sourcepub fn topic2<P>(self, topic: Topic<P>) -> Selfwhere
P: Tokenize,
pub fn topic2<P>(self, topic: Topic<P>) -> Selfwhere
P: Tokenize,
Adds a filter for the third indexed topic.
sourcepub fn limit(self, value: usize) -> Self
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.
sourcepub fn poll_interval(self, value: Duration) -> Self
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.
sourcepub fn into_inner(self) -> Result<(AbiEvent, LogFilterBuilder<T>), EventError>
pub fn into_inner(self) -> Result<(AbiEvent, LogFilterBuilder<T>), EventError>
Returns a LogFilterBuilder instance for the current builder.
sourcepub async fn query(self) -> Result<Vec<Event<E>>, EventError>
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.
sourcepub fn stream(self) -> impl Stream<Item = Result<StreamEvent<E>, EventError>>
pub fn stream(self) -> impl Stream<Item = Result<StreamEvent<E>, EventError>>
Creates an event stream from the current event builder that emits new events.