Constructionopen, find, into_async, into_inner

fn open(path: impl AsRef<Path>) -> Result<AsyncDevice>

Blocks

fn find() -> Result<AsyncDevice>

Blocks

fn into_async(self) -> AsyncDevice

No round-trip

fn into_inner(self) -> Device

No round-trip

CONSTRUCTORS
NameDescription
openOpens a serial-port path and runs the handshake, blocking like Device::open.
findOpens the first Medius box by USB id and runs the handshake, blocking like Device::find.
into_asyncReinterprets an open Device at zero cost, over the same Link core. No new connection.
into_innerReturns the sync Device.
EXAMPLE
// find, open and handshake (blocks)
let device = AsyncDevice::find()?;

// or by path:
let device = AsyncDevice::open("/dev/ttyACM0")?;

// or reinterpret an open Device:
let device = Device::find()?.into_async();

Everything else on Device is mirrored on AsyncDevice and stays synchronous, including counters, logs, reapply, and reconnect.

QueriesEvery query method is a future

async fn query_version(&self) -> Result<Version>

Blocks

async fn query_health(&self) -> Result<Health>

Blocks

Each future awaits the correlated RESP with the default timeout, then resolves to its struct.

RETURNS
MethodResolves toDescription
query_version().awaitVersionFirmware identity.
query_health().awaitHealthWhether the box is wired and ready.

Every other query resolves the same way. The full list is on Requests.

EXAMPLE
async fn run(device: &AsyncDevice) -> medius::Result<()> {
    let v = device.query_version().await?;
    let h = device.query_health().await?;
    println!("{v}, link_up={}", h.link_up);
    Ok(())
}