Serial

Struct Serial 

Source
pub struct Serial {
    _p: (),
}
Expand description

A serial teletype interface for x86_64 systems.

This struct provides a basic implementation of a serial TTY using the COM1 serial port. It implements the Teletype trait to allow read and write operations over a serial interface.

Fields§

§_p: ()

Implementations§

Source§

impl Serial

Source

pub const fn new() -> Self

Creates a new COM1 serial interface instance.

This function initializes a serial TTY for performing character-based I/O operations. The actual hardware interaction is handled via the Teletype trait methods (write and read).

§Returns
  • A new instance of Serial, representing a COM1 serial interface.

Trait Implementations§

Source§

impl Default for Serial

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Teletype for Serial

Source§

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

Writes data to the serial teletype (COM1).

This function attempts to convert the input byte slice into a UTF-8 string. If the conversion is successful, it prints the string to the console. If the data is aligned to a 16-byte boundary, it is printed as a single string; otherwise, it is printed byte by byte.

§Arguments
  • data: The byte slice to be written.
§Returns
  • Ok(usize): The number of bytes written.
  • Err: If the input data is not valid UTF-8.
Source§

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

Reads data from the serial teletype (COM1).

This function retrieves data from the serial interface and stores it in the provided mutable buffer.

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

Auto Trait Implementations§

§

impl Freeze for Serial

§

impl RefUnwindSafe for Serial

§

impl Send for Serial

§

impl Sync for Serial

§

impl Unpin for Serial

§

impl UnwindSafe for Serial

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.