You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
806 B
Rust
36 lines
806 B
Rust
//! The trait implemented by console structures.
|
|
|
|
use core::fmt;
|
|
|
|
/// Trait allowing a structure to be used as a console.
|
|
pub trait Console: Write {}
|
|
|
|
/// Trait allowing to write to an object.
|
|
pub trait Write {
|
|
/// Write a single character.
|
|
fn write_char(&self, c: char);
|
|
|
|
/// Write a Rust format string.
|
|
fn write_fmt(&self, args: fmt::Arguments) -> fmt::Result;
|
|
|
|
/// Block until the last buffered character has been consumed.
|
|
fn flush(&self);
|
|
}
|
|
|
|
/// A Dummy Console.
|
|
///
|
|
/// The DummyConsole implement the [`Console`] trait, and do nothing.
|
|
pub struct DummyConsole;
|
|
|
|
impl Write for DummyConsole {
|
|
fn write_char(&self, _c: char) {}
|
|
|
|
fn write_fmt(&self, _args: fmt::Arguments) -> fmt::Result {
|
|
Ok(())
|
|
}
|
|
|
|
fn flush(&self) {}
|
|
}
|
|
|
|
impl Console for DummyConsole {}
|