DisplayDriver

Struct DisplayDriver 

Source
pub struct DisplayDriver<T: DynamicWidget> { /* private fields */ }
Expand description

Represents a display driver responsible for handling the interaction between the displays and the terminal.

Implementations§

Source§

impl<T: DynamicWidget> DisplayDriver<T>

Source

pub fn new(widget: T) -> Self

Convenience method to build a blank display struct with specified dimensions

Source

pub fn print_display(&self) -> Result<(), Error>

Prints the display to the terminal.

§Errors

May return an error if write! is unsuccessful.

Source

pub fn initialize(&mut self) -> Result<(), Error>

Initializes the display driver. This function enables terminal raw mode and sets the dimensions of the screen to match the widget’s dimensions. It enters alternate screen mode, hides the cursor and disables line wrapping.

§Errors

Returns an error when any on the actions above fail. Note that resizing the terminal does not fail, if the terminal does not support it.

Source

pub fn set_on_update<F>(&mut self, on_update: F)
where F: FnMut(&mut Self, Option<KeyEvent>) -> UpdateStatus + 'static,

Source

pub const fn set_target_frame_time(&mut self, frame_time: Duration)

Source

pub fn set_target_frame_rate(&mut self, frame_rate: f32)

Source

pub fn update(&mut self)

This function encapsulates the update loop of the display. As such it may or may not return depending on the update callback set with set_on_update. This function prints the display. Queries user input and exits on Ctrl-C. Forwards keystrokes to the provided callback and invokes it. Sleeps so the target frame rate is not exceeded.

§Panics

This function panics when the display could not be printed.

Trait Implementations§

Source§

impl<T: DynamicWidget> Deref for DisplayDriver<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: DynamicWidget> DerefMut for DisplayDriver<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: DynamicWidget> Drop for DisplayDriver<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for DisplayDriver<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for DisplayDriver<T>

§

impl<T> !Send for DisplayDriver<T>

§

impl<T> !Sync for DisplayDriver<T>

§

impl<T> Unpin for DisplayDriver<T>
where T: Unpin,

§

impl<T> !UnwindSafe for DisplayDriver<T>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.