pub trait Console {
Show 33 methods
// Required methods
fn clear(&mut self, how: ClearType) -> Result<()>;
fn color(&self) -> (Option<u8>, Option<u8>);
fn set_color(&mut self, fg: Option<u8>, bg: Option<u8>) -> Result<()>;
fn enter_alt(&mut self) -> Result<()>;
fn hide_cursor(&mut self) -> Result<()>;
fn is_interactive(&self) -> bool;
fn leave_alt(&mut self) -> Result<()>;
fn locate(&mut self, pos: CharsXY) -> Result<()>;
fn move_within_line(&mut self, off: i16) -> Result<()>;
fn print(&mut self, text: &str) -> Result<()>;
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 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 show_cursor(&mut self) -> Result<()>;
fn size_chars(&self) -> Result<CharsXY>;
fn write(&mut self, text: &str) -> Result<()>;
fn sync_now(&mut self) -> Result<()>;
fn set_sync(&mut self, _enabled: bool) -> Result<bool>;
// Provided methods
fn size_pixels(&self) -> Result<SizeInPixels> { ... }
fn glyph_size(&self) -> Result<SizeInPixels> { ... }
fn bucket_fill(&mut self, _xy: PixelsXY) -> Result<()> { ... }
fn draw_circle(&mut self, _center: PixelsXY, _radius: u16) -> Result<()> { ... }
fn draw_circle_filled(
&mut self,
_center: PixelsXY,
_radius: u16,
) -> Result<()> { ... }
fn draw_line(&mut self, _x1y1: PixelsXY, _x2y2: PixelsXY) -> Result<()> { ... }
fn draw_pixel(&mut self, _xy: PixelsXY) -> Result<()> { ... }
fn draw_poly(&mut self, _points: &[PixelsXY]) -> Result<()> { ... }
fn draw_poly_filled(&mut self, _points: &[PixelsXY]) -> Result<()> { ... }
fn draw_rect(&mut self, _x1y1: PixelsXY, _x2y2: PixelsXY) -> Result<()> { ... }
fn draw_rect_filled(
&mut self,
_x1y1: PixelsXY,
_x2y2: PixelsXY,
) -> Result<()> { ... }
fn draw_tri(
&mut self,
_x1y1: PixelsXY,
_x2y2: PixelsXY,
_x3y3: PixelsXY,
) -> Result<()> { ... }
fn draw_tri_filled(
&mut self,
_x1y1: PixelsXY,
_x2y2: PixelsXY,
_x3y3: PixelsXY,
) -> Result<()> { ... }
fn peek_pixel(&self, _xy: PixelsXY) -> Result<Option<u8>> { ... }
fn beep<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn play_tone<'life0, 'async_trait>(
&'life0 mut self,
_tone: Tone,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Hooks to implement the commands that manipulate the console.
Required Methods§
Sourcefn color(&self) -> (Option<u8>, Option<u8>)
fn color(&self) -> (Option<u8>, Option<u8>)
Gets the console’s current foreground and background colors.
Sourcefn set_color(&mut self, fg: Option<u8>, bg: Option<u8>) -> Result<()>
fn set_color(&mut self, fg: Option<u8>, bg: Option<u8>) -> Result<()>
Sets the console’s foreground and background colors to fg and bg.
If any of the colors is None, the color is left unchanged.
Sourcefn hide_cursor(&mut self) -> Result<()>
fn hide_cursor(&mut self) -> Result<()>
Hides the cursor.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
The input text is not supposed to contain any control characters, such as CR or LF.
Sourcefn 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.
Sourcefn 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.
Sourcefn show_cursor(&mut self) -> Result<()>
fn show_cursor(&mut self) -> Result<()>
Shows the cursor.
Sourcefn size_chars(&self) -> Result<CharsXY>
fn size_chars(&self) -> Result<CharsXY>
Queries the size of the text console.
The returned position represents the first row and column that lay outside of the console.
Sourcefn 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.
Sourcefn sync_now(&mut self) -> Result<()>
fn sync_now(&mut self) -> Result<()>
Causes any buffered output to be synced.
This is a no-op when video syncing is enabled because output is never buffered in that case.
Sourcefn set_sync(&mut self, _enabled: bool) -> Result<bool>
fn set_sync(&mut self, _enabled: bool) -> Result<bool>
Enables or disables video syncing.
When enabled, all graphical operations immediately updated the rendering target, which is useful for interactive behavior because we want to see an immediate response. When disabled, all operations are buffered, which is useful for scripts (as otherwise rendering is too slow).
Flushes any pending updates when enabled.
Returns the previous status of the video syncing flag.
Provided Methods§
Sourcefn size_pixels(&self) -> Result<SizeInPixels>
fn size_pixels(&self) -> Result<SizeInPixels>
Queries the size of the graphical console.
Sourcefn glyph_size(&self) -> Result<SizeInPixels>
fn glyph_size(&self) -> Result<SizeInPixels>
Queries the size of a single glyph in the graphical console.
Sourcefn bucket_fill(&mut self, _xy: PixelsXY) -> Result<()>
fn bucket_fill(&mut self, _xy: PixelsXY) -> Result<()>
Fills the 4-connected region around _xy using the current drawing color.
Sourcefn draw_circle(&mut self, _center: PixelsXY, _radius: u16) -> Result<()>
fn draw_circle(&mut self, _center: PixelsXY, _radius: u16) -> Result<()>
Draws the outline of a circle at _center with _radius using the current drawing color.
Sourcefn draw_circle_filled(&mut self, _center: PixelsXY, _radius: u16) -> Result<()>
fn draw_circle_filled(&mut self, _center: PixelsXY, _radius: u16) -> Result<()>
Draws a filled circle at _center with _radius using the current drawing color.
Sourcefn 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.
Sourcefn 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.
Sourcefn draw_poly(&mut self, _points: &[PixelsXY]) -> Result<()>
fn draw_poly(&mut self, _points: &[PixelsXY]) -> Result<()>
Draws the outline of a polygon using the current drawing color.
Sourcefn draw_poly_filled(&mut self, _points: &[PixelsXY]) -> Result<()>
fn draw_poly_filled(&mut self, _points: &[PixelsXY]) -> Result<()>
Draws a filled polygon using the current drawing color.
Sourcefn 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.
Sourcefn draw_rect_filled(&mut self, _x1y1: PixelsXY, _x2y2: PixelsXY) -> Result<()>
fn draw_rect_filled(&mut self, _x1y1: PixelsXY, _x2y2: PixelsXY) -> Result<()>
Draws a filled rectangle from _x1y1 to _x2y2 using the current drawing color.
Sourcefn draw_tri(
&mut self,
_x1y1: PixelsXY,
_x2y2: PixelsXY,
_x3y3: PixelsXY,
) -> Result<()>
fn draw_tri( &mut self, _x1y1: PixelsXY, _x2y2: PixelsXY, _x3y3: PixelsXY, ) -> Result<()>
Draws the outline of a triangle using the current drawing color.
Sourcefn draw_tri_filled(
&mut self,
_x1y1: PixelsXY,
_x2y2: PixelsXY,
_x3y3: PixelsXY,
) -> Result<()>
fn draw_tri_filled( &mut self, _x1y1: PixelsXY, _x2y2: PixelsXY, _x3y3: PixelsXY, ) -> Result<()>
Draws a filled triangle using the current drawing color.
Sourcefn peek_pixel(&self, _xy: PixelsXY) -> Result<Option<u8>>
fn peek_pixel(&self, _xy: PixelsXY) -> Result<Option<u8>>
Returns the color number of the pixel at _xy if it is in bounds and exactly mappable.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".