Skip to main content

Machine

Struct Machine 

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

A calculator link without I/O. See the module documentation.

Implementations§

Source§

impl Machine

Source

pub fn new(now: Instant, options: Options, seed: u64) -> Self

A machine for a newly opened link at now. seed should be random (it picks the sync markers that tell this connection’s replies from a late one of an earlier client).

Source

pub fn set_xserv_options(&mut self, options: XservOptions)

The XSERV operations’ timing (default XservOptions::default). Takes effect at once while idle, else after the running operation.

Source

pub fn start(&mut self, now: Instant, op: Op) -> Result<(), Busy>

Begin op; its first bytes are ready for Machine::poll_transmit at once. A result not yet taken with Machine::poll_result is dropped.

Source

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

Feed bytes read from the link at now.

Source

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

Tell the machine the time is now.

The link failed or closed (a closed port is io::ErrorKind::UnexpectedEof): the running operation fails with Error::Io, except that a Kermit or XModem transfer already complete keeps its result. The next Machine::start clears the error.

Source

pub fn poll_transmit(&mut self) -> Option<Vec<u8>>

The next chunk to write, one write each.

Source

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

The next progress event.

Source

pub fn set_events(&mut self, keep: bool)

Whether progress events are kept for Machine::poll_event (default true). Off, they are dropped as they happen.

Source

pub fn poll_result(&mut self) -> Option<Result<Reply>>

The result of the last operation, once it is over.

Source

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

When to call Machine::handle_timeout at the latest; None while no operation runs.

Source

pub fn is_busy(&self) -> bool

Whether an operation runs.

Source

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

Drop the running operation at once, without telling the calculator. Queued bytes are forgotten; the calculator may still be in the middle of a transaction and answers the next command late, which the next Op::Connect or Op::Sync sorts out. The cached transfer mode is forgotten; the session keeps its options. No-op when idle.

Trait Implementations§

Source§

impl Debug for Machine

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.