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.
54 lines
1.4 KiB
Rust
54 lines
1.4 KiB
Rust
5 years ago
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||
|
//
|
||
4 years ago
|
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||
5 years ago
|
|
||
|
//! System console.
|
||
|
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
// Public Definitions
|
||
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
||
|
/// Console interfaces.
|
||
|
pub mod interface {
|
||
|
use core::fmt;
|
||
|
|
||
|
/// Console write functions.
|
||
|
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;
|
||
4 years ago
|
|
||
4 years ago
|
/// Block until the last buffered character has been physically put on the TX wire.
|
||
4 years ago
|
fn flush(&self);
|
||
5 years ago
|
}
|
||
|
|
||
|
/// Console read functions.
|
||
|
pub trait Read {
|
||
|
/// Read a single character.
|
||
|
fn read_char(&self) -> char {
|
||
|
' '
|
||
|
}
|
||
4 years ago
|
|
||
|
/// Clear RX buffers, if any.
|
||
|
fn clear_rx(&self);
|
||
5 years ago
|
}
|
||
|
|
||
|
/// Console statistics.
|
||
|
pub trait Statistics {
|
||
|
/// Return the number of characters written.
|
||
|
fn chars_written(&self) -> usize {
|
||
|
0
|
||
|
}
|
||
|
|
||
|
/// Return the number of characters read.
|
||
|
fn chars_read(&self) -> usize {
|
||
|
0
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// Trait alias for a full-fledged console.
|
||
|
pub trait All = Write + Read + Statistics;
|
||
|
}
|