ProtocolOpen

Trait ProtocolOpen 

Source
pub trait ProtocolOpen: Protocol {
    // Required method
    fn open(identifier: &str) -> Result<Self, CommunicationError>
       where Self: Sized;

    // Provided method
    fn open_with_options(
        identifier: &str,
        baudrate: u32,
        timeout: Duration,
        polling_interval: Duration,
    ) -> Result<Self, CommunicationError>
       where Self: Sized { ... }
}
Expand description

Trait for opening protocol connections

Required Methods§

Source

fn open(identifier: &str) -> Result<Self, CommunicationError>
where Self: Sized,

Open a protocol connection with basic identifier

§Arguments
  • identifier - Connection identifier (e.g., COM port, device path)
§Returns

A Result containing the opened protocol instance or an error

§Errors

Any error raised by the specific protocol library, mostly informing that the selected device does not exist.

Provided Methods§

Source

fn open_with_options( identifier: &str, baudrate: u32, timeout: Duration, polling_interval: Duration, ) -> Result<Self, CommunicationError>
where Self: Sized,

Open a protocol connection with advanced options

§Arguments
  • identifier - Connection identifier
  • baudrate - Communication baudrate (protocol-specific)
  • timeout - Operation timeout duration
  • polling_interval - Response polling interval
§Returns

A Result containing the opened protocol instance or an error

§Errors

Any error raised by the specific protocol library, mostly informing that the selected device does not exist.

§Note

Default implementation ignores advanced options and calls basic open()

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§