Struct Context

Source
pub struct Context<C: ColourConfig = DefaultColourConfig> { /* private fields */ }
Expand description

An interface to a terminal for rendering Views, and getting input.

Implementations§

Source§

impl Context<DefaultColourConfig>

Source

pub fn new() -> Result<Self>

Initialise a new context using the current terminal.

Source

pub fn from_terminal(terminal: Terminal) -> Result<Self>

Source§

impl<C: ColourConfig> Context<C>

Source

pub fn with_colour_config(colour_config: C) -> Result<Self>

Source

pub fn from_terminal_with_colour_config( terminal: Terminal, colour_config: C, ) -> Result<Self>

Source

pub fn drain_input(&mut self) -> Result<Drain<'_, Input>>

Source

pub fn poll_input(&mut self) -> Result<Option<Input>>

Gets an input event from the terminal if one is present, returning immediately.

Source

pub fn wait_input(&mut self) -> Result<Input>

Gets an input event from the terminal, waiting until an event occurs.

Source

pub fn wait_input_timeout(&mut self, timeout: Duration) -> Result<Option<Input>>

Gets an input event from the terminal, waiting until either an event occurs, or the timeout expires, in which case this method returns None.

Source

pub fn render<V: View<T>, T>(&mut self, view: &mut V, data: T) -> Result<()>

Source

pub fn render_at<V: View<T>, T, R: ViewTransformRgb24>( &mut self, view: &mut V, data: T, context: ViewContext<R>, ) -> Result<()>

Source

pub fn size(&self) -> Result<Size>

Auto Trait Implementations§

§

impl<C> Freeze for Context<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for Context<C>
where C: RefUnwindSafe,

§

impl<C> Send for Context<C>
where C: Send,

§

impl<C> Sync for Context<C>
where C: Sync,

§

impl<C> Unpin for Context<C>
where C: Unpin,

§

impl<C> UnwindSafe for Context<C>
where C: UnwindSafe,

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<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.