pub struct QueuedInputSource<M>where
M: EventMapper,{ /* private fields */ }Expand description
Pull-based input source backed by an unbounded FIFO.
A successful enqueue appends the entire mapped batch behind older pending
events. Mapping occurs in a temporary vector, so a mapping error never
commits a partial batch to the queue. The generic mapper’s own state follows
its EventMapper::map_batch contract; the queue cannot roll it back.
Implementations§
Source§impl<M> QueuedInputSource<M>where
M: EventMapper,
impl<M> QueuedInputSource<M>where
M: EventMapper,
pub fn new(mapper: M) -> Self
pub fn mapper(&self) -> &M
pub fn mapper_mut(&mut self) -> &mut M
Sourcepub fn enqueue_batch(&mut self, batch: &EventBatch) -> Result<usize, M::Error>
pub fn enqueue_batch(&mut self, batch: &EventBatch) -> Result<usize, M::Error>
Map and atomically append the logical events in one framework batch.
Physical diagnostic edges are intentionally not mapped by this adapter. On success, returns the number of downstream events appended.
Sourcepub fn enqueue_events(
&mut self,
events: &[ButtonEvent],
) -> Result<usize, M::Error>
pub fn enqueue_events( &mut self, events: &[ButtonEvent], ) -> Result<usize, M::Error>
Map and atomically append an ordered domain-event slice.
pub fn next_event(&mut self) -> Option<M::Output>
pub fn pending_len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn flush_to<S>(
&mut self,
sink: &mut S,
) -> Result<usize, FlushError<S::Error>>where
S: TryEventSink<M::Output>,
pub fn flush_to<S>(
&mut self,
sink: &mut S,
) -> Result<usize, FlushError<S::Error>>where
S: TryEventSink<M::Output>,
Try to deliver every pending event to sink in FIFO order.
When a send fails, ownership of the rejected event is returned by the sink, restored to the front of the queue, and included in the next retry. Already accepted events are removed exactly once; the untouched tail remains in its original order.