pub struct VirtIOConsole<H: Hal, T: Transport> { /* private fields */ }Expand description
Driver for a VirtIO console device.
Only a single port is supported.
§Example
use virtio_drivers::device::console::VirtIOConsole;
let mut console = VirtIOConsole::<HalImpl, _>::new(transport)?;
let size = console.size().unwrap().unwrap();
println!("VirtIO console {}x{}", size.rows, size.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>
impl<H: Hal, T: Transport> VirtIOConsole<H, T>
Sourcepub fn size(&self) -> Result<Option<Size>>
pub fn size(&self) -> Result<Option<Size>>
Returns the size of the console, if the device supports reporting this.
Sourcepub fn ack_interrupt(&mut self) -> Result<bool>
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.
Sourcepub fn recv(&mut self, pop: bool) -> Result<Option<u8>>
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>.
Sourcepub fn send_bytes(&mut self, buffer: &[u8]) -> Result
pub fn send_bytes(&mut self, buffer: &[u8]) -> Result
Sends one or more bytes to the console.
Sourcepub fn emergency_write(&mut self, chr: u8) -> Result<()>
pub fn emergency_write(&mut self, chr: u8) -> Result<()>
Sends a character to the console using the emergency write feature.
Returns an error if the device doesn’t support emergency write.
Trait Implementations§
Source§impl<H: Hal, T: Transport> BufRead for VirtIOConsole<H, T>
impl<H: Hal, T: Transport> BufRead for VirtIOConsole<H, T>
Source§impl<H: Hal, T: Transport> Read for VirtIOConsole<H, T>
impl<H: Hal, T: Transport> Read for VirtIOConsole<H, T>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
Read the exact number of bytes required to fill
buf. Read moreSource§impl<H: Hal, T: Transport> Write for VirtIOConsole<H, T>
impl<H: Hal, T: Transport> Write for VirtIOConsole<H, T>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
Write a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
Flush this output stream, blocking until all intermediately buffered contents reach their destination.
Source§impl<H: Hal, T: Transport> Write for VirtIOConsole<H, T>
impl<H: Hal, T: Transport> Write for VirtIOConsole<H, T>
impl<H: Hal, T: Transport + Send> Send for VirtIOConsole<H, T>where
VirtQueue<H, QUEUE_SIZE>: Send,
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>
impl<H, T> UnwindSafe for VirtIOConsole<H, T>where
T: UnwindSafe,
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more