Trait rustun::server::HandleMessage
source · pub trait HandleMessage {
type Attribute: Attribute + Send + 'static;
// Provided methods
fn handle_call(
&mut self,
peer: SocketAddr,
request: Request<Self::Attribute>
) -> Action<Response<Self::Attribute>> { ... }
fn handle_cast(
&mut self,
peer: SocketAddr,
indication: Indication<Self::Attribute>
) -> Action<Never> { ... }
fn handle_invalid_message(
&mut self,
peer: SocketAddr,
message: InvalidMessage
) -> Action<Response<Self::Attribute>> { ... }
fn handle_channel_error(&mut self, error: &Error) { ... }
}
Expand description
This trait allows for handling messages sent by clients.
Required Associated Types§
Provided Methods§
sourcefn handle_call(
&mut self,
peer: SocketAddr,
request: Request<Self::Attribute>
) -> Action<Response<Self::Attribute>>
fn handle_call( &mut self, peer: SocketAddr, request: Request<Self::Attribute> ) -> Action<Response<Self::Attribute>>
Handles a request message.
The default implementation always returns Action::NoReply
.
sourcefn handle_cast(
&mut self,
peer: SocketAddr,
indication: Indication<Self::Attribute>
) -> Action<Never>
fn handle_cast( &mut self, peer: SocketAddr, indication: Indication<Self::Attribute> ) -> Action<Never>
Handles an indication message.
The default implementation always returns Action::NoReply
.
sourcefn handle_invalid_message(
&mut self,
peer: SocketAddr,
message: InvalidMessage
) -> Action<Response<Self::Attribute>>
fn handle_invalid_message( &mut self, peer: SocketAddr, message: InvalidMessage ) -> Action<Response<Self::Attribute>>
Handles an invalid incoming message.
Note that this method should not return Action::Reply(_)
or Action::FutureReply(_)
if the class of message
is not MessageClass::Request
.
The default implementation always returns Action::NoReply
.
sourcefn handle_channel_error(&mut self, error: &Error)
fn handle_channel_error(&mut self, error: &Error)
Handles an error before the channel drops by the error.
The default implementation does nothing.