Skip to main content

Transfer

Struct Transfer 

Source
pub struct Transfer { /* private fields */ }
Expand description

Sans-IO XModem transfer, sender or receiver. See the crate documentation for the driver loop.

Implementations§

Source§

impl Transfer

Source

pub fn new(config: Config) -> Self

New idle machine.

Source

pub fn start( &mut self, now: Instant, command: Command, ) -> Result<(), StartError>

Begin a transfer. A sender waits for the receiver’s start character (nothing to write yet); a receiver’s first start character is available from poll_output(now) at once.

Output and events of the previous transfer that were not polled yet are dropped; a linger after it (Config::linger) ends.

Source

pub fn handle_input(&mut self, now: Instant, bytes: &[u8])

Feed bytes read from the link, in any chunking.

Source

pub fn handle_timeout(&mut self, now: Instant)

Call when the time from Transfer::next_timeout has passed (or whenever a read times out; it does nothing early).

Source

pub fn poll_output(&mut self, now: Instant) -> Option<Vec<u8>>

Next bytes to write, written atomically: a whole block, a single control byte, or the CAN sequence. Keep calling after Done/Error until None: a final ACK or the CANs may still be queued.

Source

pub fn poll_event(&mut self) -> Option<Event>

Next event, in order.

Source

pub fn next_timeout(&self) -> Option<Instant>

The earliest instant at which Transfer::handle_timeout has work.

Source

pub fn is_idle(&self) -> bool

No transfer running and no linger after one (output may still be queued).

Source

pub fn check(&self) -> Check

The check in use (receive: requested so far; settled after Event::Started).

Source

pub fn cancel(&mut self, _now: Instant)

Abort: queue the CAN sequence, emit Error(Cancelled), go idle. No-op when idle. During the linger after Done it only ends the linger: no CANs, no event.

Trait Implementations§

Source§

impl Debug for Transfer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.