Trait Port

Source
pub trait Port: MaybeNamed + MaybeLabeled {
    // Required methods
    fn id(&self) -> PortID;
    fn state(&self) -> PortState;

    // Provided methods
    fn is_closed(&self) -> bool { ... }
    fn is_open(&self) -> bool { ... }
    fn is_connected(&self) -> bool { ... }
    fn close(&mut self) -> PortResult<bool> { ... }
}
Expand description

The common interface for ports, whether for input or output.

Required Methods§

Source

fn id(&self) -> PortID

A unique identifier for this port.

Source

fn state(&self) -> PortState

The current state of this port.

Provided Methods§

Source

fn is_closed(&self) -> bool

Checks whether this port is currently closed.

Source

fn is_open(&self) -> bool

Checks whether this port is currently open.

Source

fn is_connected(&self) -> bool

Checks whether this port is currently connected.

Source

fn close(&mut self) -> PortResult<bool>

Closes this port, returning immediately.

If the port had an open connection, it will be disconnected. If the port was already closed, no further action is taken. There is no facility to reopen a port once it has been closed.

Returns Ok(true) if the port was successfully closed. Returns Ok(false) if the port was already closed. Returns Err(PortError) if an error occurs.

Trait Implementations§

Source§

impl Debug for &dyn Port

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§