Trait rabble::ServiceHandler
[−]
[src]
pub trait ServiceHandler<T> { fn handle_envelope(
&mut self,
_: &Node<T>,
_: Envelope<T>,
_: &Registrar
) -> Result<()>; fn init(&mut self, &Registrar, &Node<T>) -> Result<()> { ... } fn handle_notification(
&mut self,
&Node<T>,
Notification,
&Registrar
) -> Result<()> { ... } }
A service handler
Required Methods
fn handle_envelope(
&mut self,
_: &Node<T>,
_: Envelope<T>,
_: &Registrar
) -> Result<()>
&mut self,
_: &Node<T>,
_: Envelope<T>,
_: &Registrar
) -> Result<()>
Handle any envelopes addressed to the service's Pid. All handlers must implement this function.
Provided Methods
fn init(&mut self, &Registrar, &Node<T>) -> Result<()>
A callback function used to initialize the handler.
The handler is expected to register any necessary timeouts or listening sockets with the poller and send any initialization messages via the Node. Some handlers may not need any initialization, so this callback is optional.
fn handle_notification(
&mut self,
&Node<T>,
Notification,
&Registrar
) -> Result<()>
&mut self,
&Node<T>,
Notification,
&Registrar
) -> Result<()>
Handle poll notifications. Some handler don't register anything that requires notification and only receive envelopes. Those handlers do not need to implement this function.
Implementors
impl<'de, C, S> ServiceHandler<C::Msg> for TcpServerHandler<C, S> where
C: ConnectionHandler<ClientMsg = S::Msg>,
S: Serialize,
C::Msg: Serialize + Deserialize<'de> + Clone + Debug,