pub struct MockConsole { /* private fields */ }
Expand description
A console that supplies golden input and captures all output.
Implementations§
Source§impl MockConsole
impl MockConsole
Sourcepub fn add_input_chars(&mut self, s: &str)
pub fn add_input_chars(&mut self, s: &str)
Adds a bunch of characters as golden input keys.
Note that some escape characters within s
are interpreted and added as their
corresponding Key
s for simplicity.
Sourcepub fn add_input_keys(&mut self, keys: &[Key])
pub fn add_input_keys(&mut self, keys: &[Key])
Adds a bunch of keys as golden input.
Sourcepub fn captured_out(&self) -> &[CapturedOut]
pub fn captured_out(&self) -> &[CapturedOut]
Obtains a reference to the captured output.
Sourcepub fn take_captured_out(&mut self) -> Vec<CapturedOut>
pub fn take_captured_out(&mut self) -> Vec<CapturedOut>
Takes the captured output for separate analysis.
Sourcepub fn set_size_chars(&mut self, size: CharsXY)
pub fn set_size_chars(&mut self, size: CharsXY)
Sets the size of the mock text console.
Sourcepub fn set_size_pixels(&mut self, size: SizeInPixels)
pub fn set_size_pixels(&mut self, size: SizeInPixels)
Sets the size of the mock graphical console.
Sourcepub fn set_interactive(&mut self, interactive: bool)
pub fn set_interactive(&mut self, interactive: bool)
Sets whether the mock console is interactive or not.
Trait Implementations§
Source§impl Console for MockConsole
impl Console for MockConsole
Source§fn clear(&mut self, how: ClearType) -> Result<()>
fn clear(&mut self, how: ClearType) -> Result<()>
Clears the part of the console given by
how
.Source§fn color(&self) -> (Option<u8>, Option<u8>)
fn color(&self) -> (Option<u8>, Option<u8>)
Gets the console’s current foreground and background colors.
Source§fn hide_cursor(&mut self) -> Result<()>
fn hide_cursor(&mut self) -> Result<()>
Hides the cursor.
Source§fn is_interactive(&self) -> bool
fn is_interactive(&self) -> bool
Returns true if the console is attached to an interactive terminal. This controls whether
reading a line echoes back user input, for example.
Source§fn locate(&mut self, pos: CharsXY) -> Result<()>
fn locate(&mut self, pos: CharsXY) -> Result<()>
Moves the cursor to the given position, which must be within the screen.
Source§fn move_within_line(&mut self, off: i16) -> Result<()>
fn move_within_line(&mut self, off: i16) -> Result<()>
Moves the cursor within the line. Positive values move right, negative values move left.
Source§fn print(&mut self, text: &str) -> Result<()>
fn print(&mut self, text: &str) -> Result<()>
Writes
text
to the console, followed by a newline or CRLF pair depending on the needs of
the console to advance a line. Read moreSource§fn poll_key<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<Key>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn poll_key<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<Key>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns the next key press if any is available.
Source§fn read_key<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Key>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_key<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Key>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Waits for and returns the next key press.
Source§fn show_cursor(&mut self) -> Result<()>
fn show_cursor(&mut self) -> Result<()>
Shows the cursor.
Source§fn size_pixels(&self) -> Result<SizeInPixels>
fn size_pixels(&self) -> Result<SizeInPixels>
Queries the size of the graphical console.
Source§fn write(&mut self, text: &str) -> Result<()>
fn write(&mut self, text: &str) -> Result<()>
Writes the text into the console at the position of the cursor.
Source§fn draw_circle(&mut self, xy: PixelsXY, r: u16) -> Result<()>
fn draw_circle(&mut self, xy: PixelsXY, r: u16) -> Result<()>
Draws the outline of a circle at
_center
with _radius
using the current drawing color.Source§fn draw_circle_filled(&mut self, xy: PixelsXY, r: u16) -> Result<()>
fn draw_circle_filled(&mut self, xy: PixelsXY, r: u16) -> Result<()>
Draws a filled circle at
_center
with _radius
using the current drawing color.Source§fn draw_line(&mut self, x1y1: PixelsXY, x2y2: PixelsXY) -> Result<()>
fn draw_line(&mut self, x1y1: PixelsXY, x2y2: PixelsXY) -> Result<()>
Draws a line from
_x1y1
to _x2y2
using the current drawing color.Source§fn draw_pixel(&mut self, xy: PixelsXY) -> Result<()>
fn draw_pixel(&mut self, xy: PixelsXY) -> Result<()>
Draws a single pixel at
_xy
using the current drawing color.Source§fn draw_rect(&mut self, x1y1: PixelsXY, x2y2: PixelsXY) -> Result<()>
fn draw_rect(&mut self, x1y1: PixelsXY, x2y2: PixelsXY) -> Result<()>
Draws the outline of a rectangle from
_x1y1
to _x2y2
using the current drawing color.Source§impl Default for MockConsole
impl Default for MockConsole
Auto Trait Implementations§
impl Freeze for MockConsole
impl RefUnwindSafe for MockConsole
impl Send for MockConsole
impl Sync for MockConsole
impl Unpin for MockConsole
impl UnwindSafe for MockConsole
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