Teletype

Trait Teletype 

Source
pub trait Teletype {
    // Required methods
    fn write(&mut self, data: &[u8]) -> Result<usize, KernelError>;
    fn read(&mut self, data: &mut [u8]) -> Result<usize, KernelError>;
}
Expand description

The Teletype trait represents a generic character-based input/output device.

Implementations of this trait define methods for:

  • Writing data to the teletype (write)
  • Reading data from the teletype (read)

This abstraction allows for different kinds of terminal or serial interfaces to implement their own communication methods.

Required Methods§

Source

fn write(&mut self, data: &[u8]) -> Result<usize, KernelError>

Writes data to the teletype.

§Arguments
  • data: A byte slice containing the data to be written.
§Returns
  • Ok(usize): The number of bytes successfully written.
  • Err(KernelError): If the write operation failed.
Source

fn read(&mut self, data: &mut [u8]) -> Result<usize, KernelError>

Reads data from the teletype.

§Arguments
  • data: A mutable byte slice where the read data will be stored.
§Returns
  • Ok(usize): The number of bytes successfully read.
  • Err(KernelError): If the read operation failed.

Implementors§