Skip to main content

CProtocolHandler

Trait CProtocolHandler 

Source
pub trait CProtocolHandler<T> {
    // Required methods
    fn id(&mut self) -> String;
    fn get_message(&mut self, request: &str) -> Result<T, Error>;
    fn is_running(&self) -> bool;
    fn post_message(&mut self, data: T) -> Result<(), Error>;
    fn terminate(&mut self);
}
Expand description

Defines a trait for the “rules” of objects that will setup a protocol that directly exchanges data with an external item, will continuously run until terminated, requires the ability to know it is running and get any errors that have occurred during it run.

Required Methods§

Source

fn id(&mut self) -> String

Identifies the protocol for debugging / reporting purposes.

Source

fn get_message(&mut self, request: &str) -> Result<T, Error>

Retrieves any currently processed messages. Also provide support for string commands to further support the given protocol you build.

Source

fn is_running(&self) -> bool

Signals if the protocol is running or not.

Source

fn post_message(&mut self, data: T) -> Result<(), Error>

Handles the sending of the message to the protocol for processing.

Source

fn terminate(&mut self)

Signals for the protocol to terminate.

Implementors§

Source§

impl CProtocolHandler<CSerialPortData> for CSerialPortProtocol

The CSerialPortProtocol implementation of the CProtocolHandler utilizing the CSerialPortData enumeration as the bi-directional read / write method of the protocol definition rules.

Source§

impl CProtocolHandler<CWebSocketData> for CWebSocketProtocol

Implementation of the CProtocolHandler to wrap the rouille::websocket::Websocket into this modules protocol rules. There usage further explained.

Source§

impl CProtocolHandler<String> for CProcessProtocol

Implements the CProtocolHandler for the CProcessProtocol. While the process wrapped by the protocol is in its own operating system process meaning it won’t block your application processing, any call to CProcessProtocol::get_message and CProcessProtocol::post_message are synchronous calls. No thread is implemented as part of this CProtocolHandler.

Source§

impl<T> CProtocolHandler<Option<T>> for CWorkerProtocol<Option<T>>