pub struct EventSubscription { /* private fields */ }Expand description
A subscription to scanner events that requires proof the scanner has started.
Created by EventScanner::subscribe(), this type holds the
underlying stream but prevents access until stream() is called
with a valid StartProof.
This pattern ensures at compile time that EventScanner::start() is called before attempting to
read from the event stream.
§Example
let mut scanner = EventScannerBuilder::live().connect(provider).await?;
let filter = EventFilter::new().contract_address(contract_address);
// Create subscription (cannot access stream yet)
let subscription = scanner.subscribe(filter);
// Start scanner and get proof of it starting
let proof = scanner.start().await?;
// Now access the stream with the proof
let mut stream = subscription.stream(&proof);
while let Some(msg) = stream.next().await {
// process events
}Implementations§
Source§impl EventSubscription
impl EventSubscription
Sourcepub fn stream(self, _proof: &StartProof) -> ReceiverStream<EventScannerResult>
pub fn stream(self, _proof: &StartProof) -> ReceiverStream<EventScannerResult>
Access the event stream.
Requires a reference to a StartProof as proof that the scanner
has been started. The proof is obtained by calling
EventScanner::start().
§Arguments
_proof- Proof that the scanner has been started
Auto Trait Implementations§
impl Freeze for EventSubscription
impl RefUnwindSafe for EventSubscription
impl Send for EventSubscription
impl Sync for EventSubscription
impl Unpin for EventSubscription
impl UnsafeUnpin for EventSubscription
impl UnwindSafe for EventSubscription
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more