pub trait Device<C>: Send {
type Snapshot: Serialize + Send + Sync;
// Required methods
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn poll<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Self::Snapshot>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn handle_command<'life0, 'async_trait>(
&'life0 mut self,
command: C,
connected: bool,
) -> Pin<Box<dyn Future<Output = Result<CommandEffect>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn poll_interval(&self) -> Option<Duration> { ... }
}Expand description
Device-specific connection, polling, and control operations.
The adapter owns the concrete protocol client. A failed connect or poll
causes the runner to retry with exponential backoff; command validation
errors are logged and do not by themselves drop the connection. The adapter
can explicitly request reconnection with CommandEffect::Reconnect.
Required Associated Types§
Required Methods§
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn poll<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Self::Snapshot>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_command<'life0, 'async_trait>(
&'life0 mut self,
command: C,
connected: bool,
) -> Pin<Box<dyn Future<Output = Result<CommandEffect>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
Sourcefn poll_interval(&self) -> Option<Duration>
fn poll_interval(&self) -> Option<Duration>
Allows commands to change the polling interval at runtime.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".