pub trait HandlePortEvent: 'static + Send {
// Required methods
fn message<'a>(
&mut self,
control: &mut PortControl<'_, 'a>,
message: Message<'a>,
) -> Result<(), HandleMessageError>;
fn close(&mut self, control: &mut PortControl<'_, '_>);
fn fail(&mut self, control: &mut PortControl<'_, '_>, err: NodeError);
fn drain(&mut self) -> Vec<OwnedMessage>;
}
Expand description
Trait implemented by port event handlers.
Such an implementation can be associated with a port by calling
Port::set_handler
.
Required Methods§
Sourcefn message<'a>(
&mut self,
control: &mut PortControl<'_, 'a>,
message: Message<'a>,
) -> Result<(), HandleMessageError>
fn message<'a>( &mut self, control: &mut PortControl<'_, 'a>, message: Message<'a>, ) -> Result<(), HandleMessageError>
Handles a new message for the port.
If an error is returned, the port will be failed (and the caller will
call the fail
method).
Sourcefn close(&mut self, control: &mut PortControl<'_, '_>)
fn close(&mut self, control: &mut PortControl<'_, '_>)
Handles the port closing.
Sourcefn fail(&mut self, control: &mut PortControl<'_, '_>, err: NodeError)
fn fail(&mut self, control: &mut PortControl<'_, '_>, err: NodeError)
Handles a port failure.
Sourcefn drain(&mut self) -> Vec<OwnedMessage>
fn drain(&mut self) -> Vec<OwnedMessage>
Returns all unconsumed messages.
This is used when the handler is being released, such as when sending the port to another node.