Trait canadensis::TransferHandler
source · pub trait TransferHandler<I: Instant, T: Transport> {
// 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_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 handle_loopback<N: Node<Instant = I, Transport = T>>(
&mut self,
_node: &mut N,
_transfer: &Transfer<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§
sourcefn 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 does not handle any loopback transfers.
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.
sourcefn 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 does not handle any loopback transfers.
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.
sourcefn 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 does not handle any loopback transfers.
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.
sourcefn handle_loopback<N: Node<Instant = I, Transport = T>>(
&mut self,
_node: &mut N,
_transfer: &Transfer<Vec<u8>, I, T>
) -> bool
fn handle_loopback<N: Node<Instant = I, Transport = T>>( &mut self, _node: &mut N, _transfer: &Transfer<Vec<u8>, I, T> ) -> bool
Potentially handles a loopback transfer sent from this node
All loopback transfers (message, request, and response) are handled here.
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.
sourcefn 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.