Trait cocaine::Dispatch [] [src]

pub trait Dispatch: Send {
    fn process(self: Box<Self>, response: &Response) -> Option<Box<Dispatch>>;
fn discard(self: Box<Self>, err: &Error); }

Receiver part of every multiplexed non-mute request performed with a service.

Implementors of this trait are used to be passed into the Service.call method to accumulate response chunks.

It is guaranteed that at least one of the process or discard methods will be called at least once during a channel lifetime. Note, that discard method can be called no more than once.

Required Methods

Processes a new incoming message from a service.

This method is called on every valid frame received from a service for an associated channel with message type and arguments provided. Usually the next step performed is arguments deserialization using deserialize function.

Passing Some(..) as a result type forces the multiplexer to re-register either new or the same Dispatch for processing new messages from the same channel again. Returning None terminates channel processing. It is also possible to completely switch dispatches at runtime, because of dynamic dispatching.

Discards the dispatch due to some error occurred during receiving the response.

This is the terminate state of any dispatch call graph. No more Dispatch calls will be performed, because this method accepts a boxed dispatch by value.

Implementors