pub struct Machine { /* private fields */ }Expand description
A calculator link without I/O. See the module documentation.
Implementations§
Source§impl Machine
impl Machine
Sourcepub fn new(now: Instant, options: Options, seed: u64) -> Self
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).
Sourcepub fn set_xserv_options(&mut self, options: XservOptions)
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.
Sourcepub fn start(&mut self, now: Instant, op: Op) -> Result<(), Busy>
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.
Sourcepub fn handle_input(&mut self, now: Instant, bytes: &[u8])
pub fn handle_input(&mut self, now: Instant, bytes: &[u8])
Feed bytes read from the link at now.
Sourcepub fn handle_timeout(&mut self, now: Instant)
pub fn handle_timeout(&mut self, now: Instant)
Tell the machine the time is now.
Sourcepub fn handle_link_error(&mut self, now: Instant, error: &Error)
pub fn handle_link_error(&mut self, now: Instant, error: &Error)
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.
Sourcepub fn poll_transmit(&mut self) -> Option<Vec<u8>>
pub fn poll_transmit(&mut self) -> Option<Vec<u8>>
The next chunk to write, one write each.
Sourcepub fn poll_event(&mut self) -> Option<Progress>
pub fn poll_event(&mut self) -> Option<Progress>
The next progress event.
Sourcepub fn set_events(&mut self, keep: bool)
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.
Sourcepub fn poll_result(&mut self) -> Option<Result<Reply>>
pub fn poll_result(&mut self) -> Option<Result<Reply>>
The result of the last operation, once it is over.
Sourcepub fn next_timeout(&self) -> Option<Instant>
pub fn next_timeout(&self) -> Option<Instant>
When to call Machine::handle_timeout at the latest; None while
no operation runs.
Sourcepub fn abort(&mut self, now: Instant)
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.