virtio_drivers::device::console

Struct VirtIOConsole

Source
pub struct VirtIOConsole<H: Hal, T: Transport> { /* private fields */ }
Expand description

Driver for a VirtIO console device.

Only a single port is allowed since alloc is disabled. Emergency write and cols/rows are not implemented.

§Example

use virtio_drivers::device::console::VirtIOConsole;
let mut console = VirtIOConsole::<HalImpl, _>::new(transport)?;

let info = console.info();
println!("VirtIO console {}x{}", info.rows, info.columns);

for &c in b"Hello console!\n" {
  console.send(c)?;
}

let c = console.recv(true)?;
println!("Read {:?} from console.", c);

Implementations§

Source§

impl<H: Hal, T: Transport> VirtIOConsole<H, T>

Source

pub fn new(transport: T) -> Result<Self>

Creates a new VirtIO console driver.

Source

pub fn info(&self) -> ConsoleInfo

Returns a struct with information about the console device, such as the number of rows and columns.

Source

pub fn ack_interrupt(&mut self) -> Result<bool>

Acknowledges a pending interrupt, if any, and completes the outstanding finished read request if there is one.

Returns true if new data has been received.

Source

pub fn recv(&mut self, pop: bool) -> Result<Option<u8>>

Returns the next available character from the console, if any.

If no data has been received this will not block but immediately return Ok<None>.

Source

pub fn send(&mut self, chr: u8) -> Result<()>

Sends a character to the console.

Trait Implementations§

Source§

impl<H: Hal, T: Transport> Drop for VirtIOConsole<H, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<H: Hal, T: Transport + Send> Send for VirtIOConsole<H, T>
where VirtQueue<H, QUEUE_SIZE>: Send,

Source§

impl<H: Hal, T: Transport + Sync> Sync for VirtIOConsole<H, T>
where VirtQueue<H, QUEUE_SIZE>: Sync,

Auto Trait Implementations§

§

impl<H, T> Freeze for VirtIOConsole<H, T>
where T: Freeze,

§

impl<H, T> RefUnwindSafe for VirtIOConsole<H, T>
where T: RefUnwindSafe, H: RefUnwindSafe,

§

impl<H, T> Unpin for VirtIOConsole<H, T>
where T: Unpin, H: Unpin,

§

impl<H, T> UnwindSafe for VirtIOConsole<H, T>
where T: UnwindSafe, H: UnwindSafe,

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.