pub struct StdHost;Expand description
The Host behind MMix::new(): the process’s own I/O — locked
stdout/stderr writes, stdout().flush() on halt, SystemTime for
the clock, and eprintln! for diagnostics.
write_bytes_to_fd only ever calls Host::write with fd 1 or 2 (fd 3+
reads its File from file_handles), but StdHost is a general Host
implementation, so it treats any other fd as an error rather than
assuming that invariant.
Trait Implementations§
Source§impl Host for StdHost
impl Host for StdHost
Source§fn write(&mut self, fd: u8, bytes: &[u8]) -> Result<()>
fn write(&mut self, fd: u8, bytes: &[u8]) -> Result<()>
Write raw bytes to file descriptor
fd (only 1 or 2 reach the
host — see the trait docs). Returns Ok(()) on success, matching
write_all rather than reporting a partial-write count. On success
Fputs and Fputws store bytes.len() in $255; Fputc stores 0.Source§fn flush(&mut self)
fn flush(&mut self)
Flush any buffered output.
Halt is the only event that calls this,
mirroring the process exiting without running destructors — a
program that stops via an unsimulated TRAP or the TRIP
instruction never reaches it, and MMix has no Drop. A host must
not rely on flush for correctness. No-op by default.Source§fn now_micros(&mut self) -> u64
fn now_micros(&mut self) -> u64
The current time in microseconds since the Unix epoch. The only
clock primitive
MMix needs — handle_time derives seconds and
milliseconds from it by division.Source§fn diagnostic(&mut self, msg: &str)
fn diagnostic(&mut self, msg: &str)
Report an operator-facing diagnostic message (an unsimulated
TRAP, a truncated string, a HALT/TRIP notice). StdHost sends
these to stderr via eprintln!.Auto Trait Implementations§
impl Freeze for StdHost
impl RefUnwindSafe for StdHost
impl Send for StdHost
impl Sync for StdHost
impl Unpin for StdHost
impl UnsafeUnpin for StdHost
impl UnwindSafe for StdHost
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more