pub struct Custom { /* private fields */ }Expand description
Closure-based tick strategy for app-specific logic.
§Example
use ftui_runtime::tick_strategy::{Custom, TickDecision};
let strategy = Custom::new("PriorityBased", |screen_id, tick_count, _active| {
let divisor: u64 = match screen_id {
"Dashboard" | "Messages" => 2,
"Analytics" => 10,
_ => 5,
};
if tick_count.is_multiple_of(divisor) {
TickDecision::Tick
} else {
TickDecision::Skip
}
});Implementations§
Source§impl Custom
impl Custom
Sourcepub fn new<F>(label: impl Into<String>, f: F) -> Self
pub fn new<F>(label: impl Into<String>, f: F) -> Self
Create a custom strategy with the given label and decision function.
The closure receives (screen_id, tick_count, active_screen) and
returns TickDecision::Tick or TickDecision::Skip.
Trait Implementations§
Source§impl TickStrategy for Custom
impl TickStrategy for Custom
Source§fn should_tick(
&mut self,
screen_id: &str,
tick_count: u64,
active_screen: &str,
) -> TickDecision
fn should_tick( &mut self, screen_id: &str, tick_count: u64, active_screen: &str, ) -> TickDecision
Decide whether to tick an inactive screen on this frame.
Source§fn on_screen_transition(&mut self, _from: &str, _to: &str)
fn on_screen_transition(&mut self, _from: &str, _to: &str)
Called when the runtime observes a screen transition.
Source§fn maintenance_tick(&mut self, _tick_count: u64)
fn maintenance_tick(&mut self, _tick_count: u64)
Called periodically for maintenance work.
Auto Trait Implementations§
impl Freeze for Custom
impl !RefUnwindSafe for Custom
impl Send for Custom
impl !Sync for Custom
impl Unpin for Custom
impl UnsafeUnpin for Custom
impl !UnwindSafe for Custom
Blanket Implementations§
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
Mutably borrows from an owned value. Read more