Skip to main content

Runtime

Struct Runtime 

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

Runtime that owns the main loop for draining updates and rendering.

This is intended to run on the “runtime thread” and should not be invoked from simulation threads.

Implementations§

Source§

impl Runtime

Source

pub fn new(fps: u64) -> Self

Create a runtime with a target frames-per-second value.

Examples found in repository?
examples/dummy_project/main.rs (line 30)
17fn main() -> Result<(), Box<dyn std::error::Error>> {
18    let (reporter,  mut store) = ClientStore::new();
19
20    let cluster = DummyCluster::new(4);
21    let sim_thread = thread::spawn({
22        let reporter = reporter.clone();
23        move || {
24            cluster.run(20, reporter);
25        }
26    });
27
28    #[cfg(feature = "tui")]
29    {
30        let mut runtime = Runtime::new(20);
31        runtime.run(&mut store)?;
32    }
33
34    let _ = sim_thread.join();
35    Ok(())
36}
Source

pub fn quit_on_q(self, enabled: bool) -> Self

Control whether pressing q exits the runtime loop.

Source

pub fn project_label(self, label: impl Into<String>) -> Self

Set the project label displayed at the top of the UI.

Source

pub fn run(&mut self, store: &mut ClientStore) -> Result<()>

Run the runtime loop, draining the store and drawing to the terminal.

This method blocks until the loop exits (for example, when q is pressed).

Examples found in repository?
examples/dummy_project/main.rs (line 31)
17fn main() -> Result<(), Box<dyn std::error::Error>> {
18    let (reporter,  mut store) = ClientStore::new();
19
20    let cluster = DummyCluster::new(4);
21    let sim_thread = thread::spawn({
22        let reporter = reporter.clone();
23        move || {
24            cluster.run(20, reporter);
25        }
26    });
27
28    #[cfg(feature = "tui")]
29    {
30        let mut runtime = Runtime::new(20);
31        runtime.run(&mut store)?;
32    }
33
34    let _ = sim_thread.join();
35    Ok(())
36}

Auto Trait Implementations§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V