pub struct BufferedContext<S: Service> { /* private fields */ }Expand description
A buffered service context.
This ServiceContext implementation is a wrapper around a service that provides a mailbox
for input events and a mailbox for output events. The mailboxes are implemented as FIFO queues
based on VecDeque.
The input mailbox acts as a buffer for the events that are sent to the service. The events are
enqueued into the mailbox by calling the do_send method. The mailbox
events are processed by the service on the next BufferedContext::poll call (see
poll for more details).
The service context implements Deref trait to the inner service, so it can be used as the
wrapped service itself.
Implementations§
Trait Implementations§
Source§impl<S: Service> Deref for BufferedContext<S>
impl<S: Service> Deref for BufferedContext<S>
Source§impl<S: Service> ServiceContext for BufferedContext<S>
impl<S: Service> ServiceContext for BufferedContext<S>
Source§fn do_send(&mut self, ev: S::InEvent)
fn do_send(&mut self, ev: S::InEvent)
Sends a message unconditionally, ignoring any potential errors.
The event will be enqueued into the service input mailbox and will be processed by the
service on the next BufferedContext::poll call. See poll for more details.
Source§fn poll(&mut self, cx: &mut TaskContext<'_>) -> Poll<S::OutEvent>
fn poll(&mut self, cx: &mut TaskContext<'_>) -> Poll<S::OutEvent>
Poll the service for events.
The service polling process consists of the following steps:
-
Poll the service for events. This triggers the
Service::pollmethod, allowing the service to emit events.If the
pollmethod returns aPoll::Readyevent, the polling process will stop any further polling and the event will be returned to the downstream service. -
Process all the service output mailbox events. This drains the output mailbox and returns the events to the downstream service.