pub struct Program<M, E, W = Stdout>{ /* private fields */ }Expand description
The program runtime that manages the update/view loop.
Implementations§
Source§impl<M> Program<M, CrosstermEventSource>where
M: Model,
impl<M> Program<M, CrosstermEventSource>where
M: Model,
Sourcepub fn new(model: M) -> Result<Program<M, CrosstermEventSource>, Error>
pub fn new(model: M) -> Result<Program<M, CrosstermEventSource>, Error>
Create a new program with default configuration.
Sourcepub fn with_config(
model: M,
config: ProgramConfig,
) -> Result<Program<M, CrosstermEventSource>, Error>
pub fn with_config( model: M, config: ProgramConfig, ) -> Result<Program<M, CrosstermEventSource>, Error>
Create a new program with the specified configuration.
Source§impl<M, E, W> Program<M, E, W>
impl<M, E, W> Program<M, E, W>
Sourcepub fn with_event_source(
model: M,
events: E,
backend_features: BackendFeatures,
writer: TerminalWriter<W>,
config: ProgramConfig,
) -> Result<Program<M, E, W>, Error>
pub fn with_event_source( model: M, events: E, backend_features: BackendFeatures, writer: TerminalWriter<W>, config: ProgramConfig, ) -> Result<Program<M, E, W>, Error>
Create a program with an externally-constructed event source and writer.
This is the generic entry point for alternative backends (native tty,
WASM, headless testing). The caller is responsible for terminal
lifecycle (raw mode, cleanup) — the event source should handle that
via its Drop impl or an external RAII guard.
Source§impl<M> Program<M, TtyBackend>where
M: Model,
impl<M> Program<M, TtyBackend>where
M: Model,
Sourcepub fn with_native_backend(
model: M,
config: ProgramConfig,
) -> Result<Program<M, TtyBackend>, Error>
pub fn with_native_backend( model: M, config: ProgramConfig, ) -> Result<Program<M, TtyBackend>, Error>
Create a program backed by the native TTY backend (no Crossterm).
This opens a live terminal session via ftui-tty, entering raw mode
and enabling the requested features. When the program exits (or panics),
TtyBackend::drop() restores the terminal to its original state.
Source§impl<M, E, W> Program<M, E, W>
impl<M, E, W> Program<M, E, W>
Sourcepub fn run(&mut self) -> Result<(), Error>
pub fn run(&mut self) -> Result<(), Error>
Run the main event loop.
This is the main entry point. It handles:
- Initialization (terminal setup, raw mode)
- Event polling and message dispatch
- Frame rendering
- Shutdown (terminal cleanup)
Sourcepub fn last_widget_signals(&self) -> &[WidgetSignal]
pub fn last_widget_signals(&self) -> &[WidgetSignal]
Access widget scheduling signals captured on the last render.
Sourcepub fn immediate_drain_stats(&self) -> ImmediateDrainStats
pub fn immediate_drain_stats(&self) -> ImmediateDrainStats
Snapshot immediate-drain runtime counters.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the program is running.
Sourcepub const fn tick_rate(&self) -> Option<Duration>
pub const fn tick_rate(&self) -> Option<Duration>
Get the current tick rate, if one has been installed.
Sourcepub const fn executed_cmd_count(&self) -> usize
pub const fn executed_cmd_count(&self) -> usize
Get the number of commands actually executed by the runtime.
Sourcepub fn state_registry(&self) -> Option<&Arc<StateRegistry>>
pub fn state_registry(&self) -> Option<&Arc<StateRegistry>>
Get a reference to the state registry, if configured.
Sourcepub fn has_persistence(&self) -> bool
pub fn has_persistence(&self) -> bool
Check if state persistence is enabled.
Sourcepub fn tick_strategy_stats(&self) -> Vec<(String, String)>
pub fn tick_strategy_stats(&self) -> Vec<(String, String)>
Query the current tick strategy’s debug statistics.
Returns key-value pairs describing the strategy’s internal state (e.g. strategy name, divisors, confidence, transition counts). Returns an empty vec if no tick strategy is configured.
Sourcepub fn trigger_save(&mut self) -> Result<bool, StorageError>
pub fn trigger_save(&mut self) -> Result<bool, StorageError>
Trigger a manual save of widget state.
Returns the result of the flush operation, or Ok(false) if
persistence is not configured.
Sourcepub fn trigger_load(&mut self) -> Result<usize, StorageError>
pub fn trigger_load(&mut self) -> Result<usize, StorageError>
Trigger a manual load of widget state.
Returns the number of entries loaded, or Ok(0) if persistence
is not configured.
Sourcepub fn request_redraw(&mut self)
pub fn request_redraw(&mut self)
Mark the UI as needing redraw.
Sourcepub fn request_ui_height_remeasure(&mut self)
pub fn request_ui_height_remeasure(&mut self)
Request a re-measure of inline auto UI height on next render.
Sourcepub fn start_recording(&mut self, name: impl Into<String>)
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.
Sourcepub fn stop_recording(&mut self) -> Option<InputMacro>
pub fn stop_recording(&mut self) -> Option<InputMacro>
Stop recording and return the recorded macro, if any.
Returns None if not currently recording.
Sourcepub fn is_recording(&self) -> bool
pub fn is_recording(&self) -> bool
Check if event recording is active.
Auto Trait Implementations§
impl<M, E, W = Stdout> !Freeze for Program<M, E, W>
impl<M, E, W = Stdout> !RefUnwindSafe for Program<M, E, W>
impl<M, E, W = Stdout> !Send for Program<M, E, W>
impl<M, E, W = Stdout> !Sync for Program<M, E, W>
impl<M, E, W> Unpin for Program<M, E, W>
impl<M, E, W> UnsafeUnpin for Program<M, E, W>
impl<M, E, W = Stdout> !UnwindSafe for Program<M, E, W>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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