Skip to main content

StdHost

Struct StdHost 

Source
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

Source§

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)

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

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)

Report an operator-facing diagnostic message (an unsimulated TRAP, a truncated string, a HALT/TRIP notice). StdHost sends these to stderr via eprintln!.
Source§

fn trap(&mut self, code: TrapCode, arg: u8, arg255: u64, result255: u64)

Observe a trap after handle_trap’s dispatch has run, with $255 captured both before and after. No-op by default. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more