Trait mesh::local_node::HandlePortEvent

source ·
pub trait HandlePortEvent: 'static + Send {
    // Required methods
    fn message(&mut self, control: &mut PortControl<'_>, message: Message);
    fn close(&mut self, control: &mut PortControl<'_>);
    fn fail(&mut self, control: &mut PortControl<'_>, err: NodeError);
    fn drain(&mut self) -> Vec<Message>;
}
Expand description

Trait implemented by port event handlers.

Such an implementation can be associated with a port by calling Port::set_handler.

Required Methods§

source

fn message(&mut self, control: &mut PortControl<'_>, message: Message)

Handles a new message for the port.

source

fn close(&mut self, control: &mut PortControl<'_>)

Handles the port closing.

source

fn fail(&mut self, control: &mut PortControl<'_>, err: NodeError)

Handles a port failure.

source

fn drain(&mut self) -> Vec<Message>

Returns all unconsumed messages.

This is used when the handler is being released, such as when sending the port to another node.

Implementors§