Runtime

Struct Runtime 

Source
pub struct Runtime { /* private fields */ }
Expand description

The execution engine for a vtui application.

A Runtime owns all state required to execute a component tree, including registered draw handlers, event listeners, and internal queues. It is built from a fully-declared Component and is responsible for driving the draw–update lifecycle.

§Event loop model

The runtime operates in a strict, single-threaded loop with well-defined phases:

Draws occur first in order to calculate layout for potential hit-testing events such as mouse clicks. These occur synchronously from parent to children components.

A runtime update is performed immediately after, which blocks the event loop until it can consume some event. This can range from user IO, promise completions/cancellations, tick events, and more. It is also possible for the runtime to perform batching or coalescing of events in a manner that is invariant to the draw function.

During a runtime update, a listener may potentially politely request shutdown. Once the runtime is comfortable with a shutdown, the event loop exits.

§Concurrency

The runtime is single-threaded and not Send or Sync. Concurrent systems, such as async tasks or input streams, may enqueue events via channels, but the runtime itself processes all events deterministically on one thread.

Implementations§

Source§

impl Runtime

Source

pub fn new(draw: Option<Box<dyn FnMut(DrawContext<'_>)>>) -> Self

Source

pub fn update(&mut self)

Source

pub fn draw(&mut self, frame: &mut Frame<'_>)

Source

pub fn should_exit(&self) -> bool

Trait Implementations§

Source§

impl Default for Runtime

Source§

fn default() -> Runtime

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

Auto Trait Implementations§

§

impl Freeze for Runtime

§

impl !RefUnwindSafe for Runtime

§

impl !Send for Runtime

§

impl !Sync for Runtime

§

impl Unpin for Runtime

§

impl !UnwindSafe for Runtime

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.