autd3-rs-core 0.9.0

Core types and link abstraction shared across the AUTD3 phased-array sdk crates.
Documentation
mod cycle_outcome;
mod dc_clock;
mod device_state;
mod interface;
mod into_link;
mod state_check;
mod stats;
mod status;

pub use cycle_outcome::CycleOutcome;
pub use dc_clock::{DcClock, DcObservation};
pub use device_state::DeviceState;
pub use interface::Interface;
pub use into_link::IntoLink;
pub use state_check::{ConstStateChecker, StateCheck};
pub use stats::LinkStats;
pub use status::LinkStatus;

use crate::protocol::{RX_FRAME_BYTES, TX_FRAME_BYTES};

pub trait Link: Send + 'static {
    type Error: core::error::Error + Send + Sync + 'static;
    type Checker: StateCheck;

    fn num_devices(&self) -> usize;

    fn stats(&self) -> LinkStats {
        LinkStats::default()
    }

    fn state_checker(&self) -> Self::Checker;

    fn dc_clock(&self) -> Option<DcClock> {
        None
    }

    fn wait_next_cycle(&mut self) {}

    fn cycle(
        &mut self,
        tx: &[[u8; TX_FRAME_BYTES]],
        rx: &mut [[u8; RX_FRAME_BYTES]],
    ) -> Result<CycleOutcome, Self::Error>;

    fn close(&mut self) -> Result<(), Self::Error> {
        Ok(())
    }
}