Skip to main content

Acu

Struct Acu 

Source
pub struct Acu<T: Transport, C: Clock> {
    pub reply_delay_ms: u32,
    pub retry: RetryConfig,
    /* private fields */
}
Expand description

ACU driver.

Fields§

§reply_delay_ms: u32

Reply-delay budget per attempt, in milliseconds.

§retry: RetryConfig

Retry policy applied by Acu::exchange.

Implementations§

Source§

impl<T: Transport, C: Clock> Acu<T, C>

Source

pub fn new(transport: T, clock: C) -> Self

New driver with default reply delay and retry policy.

Source

pub fn transport(&mut self) -> &mut T

Borrow the underlying transport.

Source

pub fn clock(&self) -> &C

Borrow the clock.

Source

pub fn send_to( &mut self, pd_addr: u8, pd: &mut PdState, command: &Command, ) -> Result<Vec<u8>, Error>

Encode and send command to pd_addr once. Returns the bytes written.

Source

pub fn receive(&mut self, pd: &mut PdState) -> Result<Reply, Error>

Drain whatever bytes the transport has, then attempt to parse one reply. Returns Err(Error::Timeout) once the per-attempt reply-delay budget elapses without a complete packet.

The loop reads up to a small fixed number of times per call to drain a transport that may return short reads. When the underlying transport returns Ok(0) (no more bytes immediately ready), we check the deadline and either return Timeout or immediately return — the caller is expected to call us again later.

Source

pub fn exchange( &mut self, pd_addr: u8, pd: &mut PdState, command: &Command, ) -> Result<ExchangeOutcome, Error>

Run a command/reply round-trip with full retry & off-line policy.

Auto Trait Implementations§

§

impl<T, C> Freeze for Acu<T, C>
where T: Freeze, C: Freeze,

§

impl<T, C> RefUnwindSafe for Acu<T, C>

§

impl<T, C> Send for Acu<T, C>
where T: Send, C: Send,

§

impl<T, C> Sync for Acu<T, C>
where T: Sync, C: Sync,

§

impl<T, C> Unpin for Acu<T, C>
where T: Unpin, C: Unpin,

§

impl<T, C> UnsafeUnpin for Acu<T, C>
where T: UnsafeUnpin, C: UnsafeUnpin,

§

impl<T, C> UnwindSafe for Acu<T, C>
where T: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.