Struct interchange::Requester [−][src]
pub struct Requester<I: 'static + Interchange> { /* fields omitted */ }
Requesting end of the RPC interchange.
The owner of this end initiates RPC by sending a request.
It must then either wait until the responder end responds, upon which
it can send a new request again. It does so by periodically checking
whether take_response
is Some. Or it can attempt to cancel,
which the responder may or may not honour. For details, see the
cancel
method.
Implementations
impl<I: Interchange> Requester<I>
[src]
impl<I: Interchange> Requester<I>
[src]pub fn state(&self) -> State
[src]
Current state of the interchange.
Informational only!
The responder may change this state between calls, internally atomics ensure correctness.
pub fn request(&mut self, request: &I::REQUEST) -> Result<(), ()>
[src]
Send a request to the responder.
If efficiency is a concern, or requests need multiple steps to
construct, use request_mut
and `send_request.
If the RPC state is Idle
, this always succeeds, else calling
is a logic error and the request is returned.
pub fn cancel(&mut self) -> Result<Option<I::REQUEST>, ()>
[src]
Attempt to cancel a request.
If the responder has not taken the request yet, this succeeds and returns the request.
If the responder has taken the request (is processing), we succeed and return None.
In other cases (Idle
or Reponsed
) there is nothing to cancel and we fail.
pub fn response(&mut self) -> Option<&I::RESPONSE>
[src]
Look for a response. If the responder has sent a response, we return it.
This may be called multiple times.
pub fn take_response(&mut self) -> Option<I::RESPONSE>
[src]
Look for a response. If the responder has sent a response, we return it.
This may be called only once as it move the state to Idle. If you need copies, clone the request.
impl<I: Interchange> Requester<I> where
I::REQUEST: Default,
[src]
impl<I: Interchange> Requester<I> where
I::REQUEST: Default,
[src]pub fn request_mut(&mut self) -> Option<&mut I::REQUEST>
[src]
If the interchange is idle, may build request into the returned value.
pub fn send_request(&mut self) -> Result<(), ()>
[src]
Send a request that was already placed in the interchange using request_mut
.
Trait Implementations
impl<I: Interchange> Send for Requester<I>
[src]
impl<I: Interchange> Send for Requester<I>
[src]