Type Alias SharedDevice

Source
pub type SharedDevice = Arc<Device>;
Expand description

Type alias for a shared device reference.

This is the recommended way to share a Device across multiple tasks. Since Device intentionally does not implement Clone (to prevent connection ownership ambiguity), wrapping it in Arc is the standard pattern for concurrent access.

§Example

use aranet_core::{Device, SharedDevice};
use std::sync::Arc;

let device = Device::connect("Aranet4 12345").await?;
let shared: SharedDevice = Arc::new(device);

// Clone the Arc to share across tasks
let shared_clone = Arc::clone(&shared);
tokio::spawn(async move {
    let reading = shared_clone.read_current().await;
    // ...
});

Aliased Type§

pub struct SharedDevice { /* private fields */ }