pub struct ObserverSet { /* private fields */ }Expand description
Ordered observer fan-out behind one backend callback point.
Implementations§
Source§impl ObserverSet
impl ObserverSet
Sourcepub fn new(
observers: impl IntoIterator<Item = (Digest, Box<dyn Observer>)>,
) -> Result<ObserverSet, ObserverError>
pub fn new( observers: impl IntoIterator<Item = (Digest, Box<dyn Observer>)>, ) -> Result<ObserverSet, ObserverError>
Creates a non-empty bounded observer set.
§Errors
Returns an error unless one to 16 observers are supplied and identities are unique.
Sourcepub fn single(
implementation: Digest,
observer: impl Observer + 'static,
) -> ObserverSet
pub fn single( implementation: Digest, observer: impl Observer + 'static, ) -> ObserverSet
Convenience constructor for one observer.
Sourcepub fn identity(&self) -> Result<Digest, ObserverError>
pub fn identity(&self) -> Result<Digest, ObserverError>
Returns the identity of the exact ordered observer implementations.
§Errors
Returns an error when identity serialization fails.
Sourcepub fn begin(
&mut self,
initial_position: u64,
requested_tokens: u32,
) -> Result<(), ObserverError>
pub fn begin( &mut self, initial_position: u64, requested_tokens: u32, ) -> Result<(), ObserverError>
Resets every observer for a new generation call.
§Errors
Returns a bounded error or panic from one observer.
Sourcepub fn poll(&mut self) -> Result<ControlFlow, ObserverError>
pub fn poll(&mut self) -> Result<ControlFlow, ObserverError>
Polls every observer in order before one sampling decision.
All observers run even after an earlier observer requests a stop. This
gives every sink the same pre-sampling boundary. Poll count cannot
exceed the token bound supplied to Self::begin.
§Errors
Returns a lifecycle or contained callback failure.
Sourcepub fn observe(
&mut self,
token: ObservedToken<'_>,
) -> Result<ControlFlow, ObserverError>
pub fn observe( &mut self, token: ObservedToken<'_>, ) -> Result<ControlFlow, ObserverError>
Delivers one causally admitted token to every observer in order.
A successful poll must precede delivery, and delivery cannot exceed the
token bound supplied to Self::begin.
§Errors
Returns a lifecycle or contained callback failure.
Sourcepub fn receipts(&self) -> Vec<ObserverReceipt>
pub fn receipts(&self) -> Vec<ObserverReceipt>
Returns current per-observer accounting in dispatch order.
Sourcepub fn receipt(&self, index: usize) -> Option<&ObserverReceipt>
pub fn receipt(&self, index: usize) -> Option<&ObserverReceipt>
Returns one observer receipt by dispatch index.