Client

Trait Client 

Source
pub trait Client: SlaveContext + Send {
    // Required methods
    fn call<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        request: Request<'life1>,
    ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn disconnect<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Transport independent asynchronous client trait

Required Methods§

Source

fn call<'life0, 'life1, 'async_trait>( &'life0 mut self, request: Request<'life1>, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Invokes a Modbus function.

Source

fn disconnect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Disconnects the client.

Permanently disconnects the client by shutting down the underlying stream in a graceful manner (AsyncDrop).

Dropping the client without explicitly disconnecting it beforehand should also work and free all resources. The actual behavior might depend on the underlying transport protocol (RTU/TCP) that is used by the client.

Trait Implementations§

Source§

impl From<Context> for Box<dyn Client>

Source§

fn from(val: Context) -> Self

Converts to this type from the input type.

Implementors§