Trait canadensis::TransferHandler
source · [−]pub trait TransferHandler<I: Instant, T: Transport> {
fn handle_message<N: Node<Instant = I, Transport = T>>(
&mut self,
node: &mut N,
transfer: &MessageTransfer<Vec<u8>, I, T>
) -> bool { ... }
fn handle_request<N: Node<Instant = I, Transport = T>>(
&mut self,
node: &mut N,
token: ResponseToken<T>,
transfer: &ServiceTransfer<Vec<u8>, I, T>
) -> bool { ... }
fn handle_response<N: Node<Instant = I, Transport = T>>(
&mut self,
node: &mut N,
transfer: &ServiceTransfer<Vec<u8>, I, T>
) -> bool { ... }
fn chain<H>(self, next: H) -> TransferHandlerChain<Self, H>
where
Self: Sized,
H: TransferHandler<I, T>,
{ ... }
}
Expand description
Something that may be able to handle incoming transfers
Provided methods
fn handle_message<N: Node<Instant = I, Transport = T>>(
&mut self,
node: &mut N,
transfer: &MessageTransfer<Vec<u8>, I, T>
) -> bool
fn handle_message<N: Node<Instant = I, Transport = T>>(
&mut self,
node: &mut N,
transfer: &MessageTransfer<Vec<u8>, I, T>
) -> bool
Potentially handles an incoming message transfer
This function returns true if the message was handled and should not be sent on to other handlers.
The default implementation does nothing and returns false.
fn handle_request<N: Node<Instant = I, Transport = T>>(
&mut self,
node: &mut N,
token: ResponseToken<T>,
transfer: &ServiceTransfer<Vec<u8>, I, T>
) -> bool
fn handle_request<N: Node<Instant = I, Transport = T>>(
&mut self,
node: &mut N,
token: ResponseToken<T>,
transfer: &ServiceTransfer<Vec<u8>, I, T>
) -> bool
Potentially handles an incoming service request
This function returns true if the request was handled and should not be sent on to other handlers.
The default implementation does nothing and returns false.
fn handle_response<N: Node<Instant = I, Transport = T>>(
&mut self,
node: &mut N,
transfer: &ServiceTransfer<Vec<u8>, I, T>
) -> bool
fn handle_response<N: Node<Instant = I, Transport = T>>(
&mut self,
node: &mut N,
transfer: &ServiceTransfer<Vec<u8>, I, T>
) -> bool
Potentially handles an incoming service response
This function returns true if the response was handled and should not be sent on to other handlers.
The default implementation does nothing and returns false.
fn chain<H>(self, next: H) -> TransferHandlerChain<Self, H> where
Self: Sized,
H: TransferHandler<I, T>,
fn chain<H>(self, next: H) -> TransferHandlerChain<Self, H> where
Self: Sized,
H: TransferHandler<I, T>,
Chains another handler after this handler and returns the combined handler
For each incoming transfer, this handler will be given the transfer before the next handler.