pub struct Console { /* private fields */ }Expand description
A console with a byte output buffer and a byte input queue.
Implementations§
Source§impl Console
impl Console
Sourcepub fn with_input(input: impl Into<Vec<u8>>) -> Console
pub fn with_input(input: impl Into<Vec<u8>>) -> Console
A console preloaded with input, and closed.
Closed because a caller supplying all its input at once has no more to give, and a guest that waited for more would wait forever.
Sourcepub fn output_string(&self) -> String
pub fn output_string(&self) -> String
The output interpreted as UTF-8, replacing invalid sequences.
Sourcepub fn has_input(&self) -> bool
pub fn has_input(&self) -> bool
True while input is waiting. Also the console’s interrupt condition.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Declares that no further input will arrive.
The status register then reads negative once the queue drains, which is how a guest learns to stop rather than wait.
Sourcepub fn take_starved(&mut self) -> bool
pub fn take_starved(&mut self) -> bool
True if the guest has read the status and found nothing waiting.
An interactive host polls this to know when the guest is waiting on a person, and reads a line only then. Reading the flag clears it.
Sourcepub fn push_input(&mut self, bytes: &[u8])
pub fn push_input(&mut self, bytes: &[u8])
Queues input bytes for the guest to read.