motorcortex-rust 0.5.0

Motorcortex Rust: a Rust client for the Motorcortex Core real-time control system (async + blocking).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Small helpers shared between the async handles.

use tokio::sync::oneshot;

use crate::error::{MotorcortexError, Result};

/// Await a reply from a driver command, converting a dropped channel
/// into a clear `MotorcortexError::Connection("driver dropped reply
/// channel")`. Every Cmd / SubCmd path uses this so the error is
/// uniform.
pub(crate) async fn await_reply<T>(rx: oneshot::Receiver<T>) -> Result<T> {
    rx.await
        .map_err(|_| MotorcortexError::Connection("driver dropped reply channel".into()))
}