Skip to main content

Program

Struct Program 

Source
pub struct Program<M: Model, W: Write + Send = Stdout> { /* private fields */ }
Expand description

The program runtime that manages the update/view loop.

Implementations§

Source§

impl<M: Model> Program<M, Stdout>

Source

pub fn new(model: M) -> Result<Self>
where M::Message: Send + 'static,

Create a new program with default configuration.

Source

pub fn with_config(model: M, config: ProgramConfig) -> Result<Self>
where M::Message: Send + 'static,

Create a new program with the specified configuration.

Source§

impl<M: Model, W: Write + Send> Program<M, W>

Source

pub fn run(&mut self) -> Result<()>

Run the main event loop.

This is the main entry point. It handles:

  1. Initialization (terminal setup, raw mode)
  2. Event polling and message dispatch
  3. Frame rendering
  4. Shutdown (terminal cleanup)
Source

pub fn last_widget_signals(&self) -> &[WidgetSignal]

Access widget scheduling signals captured on the last render.

Source

pub fn model(&self) -> &M

Get a reference to the model.

Source

pub fn model_mut(&mut self) -> &mut M

Get a mutable reference to the model.

Source

pub fn is_running(&self) -> bool

Check if the program is running.

Source

pub fn quit(&mut self)

Request a quit.

Source

pub fn state_registry(&self) -> Option<&Arc<StateRegistry>>

Get a reference to the state registry, if configured.

Source

pub fn has_persistence(&self) -> bool

Check if state persistence is enabled.

Source

pub fn trigger_save(&mut self) -> StorageResult<bool>

Trigger a manual save of widget state.

Returns the result of the flush operation, or Ok(false) if persistence is not configured.

Source

pub fn trigger_load(&mut self) -> StorageResult<usize>

Trigger a manual load of widget state.

Returns the number of entries loaded, or Ok(0) if persistence is not configured.

Source

pub fn request_redraw(&mut self)

Mark the UI as needing redraw.

Source

pub fn request_ui_height_remeasure(&mut self)

Request a re-measure of inline auto UI height on next render.

Source

pub fn start_recording(&mut self, name: impl Into<String>)

Start recording events into a macro.

If already recording, the current recording is discarded and a new one starts. The current terminal size is captured as metadata.

Source

pub fn stop_recording(&mut self) -> Option<InputMacro>

Stop recording and return the recorded macro, if any.

Returns None if not currently recording.

Source

pub fn is_recording(&self) -> bool

Check if event recording is active.

Auto Trait Implementations§

§

impl<M, W> Freeze for Program<M, W>
where M: Freeze, W: Freeze,

§

impl<M, W = Stdout> !RefUnwindSafe for Program<M, W>

§

impl<M, W = Stdout> !Send for Program<M, W>

§

impl<M, W = Stdout> !Sync for Program<M, W>

§

impl<M, W> Unpin for Program<M, W>
where M: Unpin, W: Unpin,

§

impl<M, W = Stdout> !UnwindSafe for Program<M, W>

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more