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§
Sourcefn get_message(&mut self, request: &str) -> Result<T, Error>
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.
Sourcefn is_running(&self) -> bool
fn is_running(&self) -> bool
Signals if the protocol is running or not.
Sourcefn post_message(&mut self, data: T) -> Result<(), Error>
fn post_message(&mut self, data: T) -> Result<(), Error>
Handles the sending of the message to the protocol for processing.
Implementors§
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.
impl CProtocolHandler<CWebSocketData> for CWebSocketProtocol
Implementation of the CProtocolHandler to wrap the rouille::websocket::Websocket into this modules protocol rules. There usage further explained.
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.