FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    DispatcherTimer

    struct · ferroui-base · v0.5.0

    struct DispatcherTimer
    

    A timer that is integrated into the Dispatcher queues, and will be processed after a given amount of time at a specified priority.

    Timers belong to the thread of their dispatcher: they are created, started and stopped there, and that is where tick handlers run. To start a timer from another thread, post a job that creates it.

    View source

    Members

    new

    fn new() -> Rc<DispatcherTimer>
    

    Creates a timer that uses the current thread's dispatcher to process the timer event at background priority.

    Source

    with_priority

    fn with_priority(priority: DispatcherPriority) -> Rc<DispatcherTimer>
    

    Creates a timer that uses the current thread's dispatcher to process the timer event at the specified priority.

    Source

    with_priority_and_dispatcher

    fn with_priority_and_dispatcher(priority: DispatcherPriority, dispatcher: &Arc<Dispatcher>) -> Rc<DispatcherTimer>
    

    Creates a timer that uses the specified dispatcher to process the timer event at the specified priority.

    Source

    with_interval

    fn with_interval(interval: Duration, priority: DispatcherPriority, dispatcher: &Arc<Dispatcher>) -> Rc<DispatcherTimer>
    

    Creates a timer that uses the specified dispatcher to process the timer event at the specified priority after the specified interval.

    Panics

    Panics when the priority is invalid or inactive, when the interval is longer than i32::MAX milliseconds and when called from a thread other than the dispatcher's.

    Source

    with_callback

    fn with_callback(interval: Duration, priority: DispatcherPriority, callback: impl Fn(&DispatcherTimer) -> () + 'static) -> Rc<DispatcherTimer>
    

    Creates a timer that is bound to the current thread's dispatcher and will be processed after the specified interval, at the specified priority, calling the specified handler. The timer is started.

    Source

    with_callback_and_dispatcher

    fn with_callback_and_dispatcher(interval: Duration, priority: DispatcherPriority, dispatcher: &Arc<Dispatcher>, callback: impl Fn(&DispatcherTimer) -> () + 'static) -> Rc<DispatcherTimer>
    

    Creates a timer that is bound to the specified dispatcher and will be processed after the specified interval, at the specified priority, calling the specified handler. The timer is started.

    Source

    dispatcher

    fn dispatcher(self: &Self) -> &Arc<Dispatcher>
    

    Gets the dispatcher this timer is associated with.

    Source

    is_enabled

    fn is_enabled(self: &Self) -> bool
    

    Gets whether the timer is running.

    Source

    set_is_enabled

    fn set_is_enabled(self: &Self, value: bool)
    

    Starts or stops the timer.

    Source

    interval

    fn interval(self: &Self) -> Duration
    

    Gets the time between timer ticks.

    Source

    set_interval

    fn set_interval(self: &Self, value: Duration)
    

    Sets the time between timer ticks.

    Source

    start

    fn start(self: &Self)
    

    Starts the timer.

    Source

    stop

    fn stop(self: &Self)
    

    Stops the timer.

    Source

    run

    fn run(action: impl Fn() -> bool + 'static, interval: Duration, priority: DispatcherPriority) -> Subscription
    

    Starts a new timer.

    action is called on each tick; the timer stops when it returns false. Dropping the returned guard (or calling Subscription::dispose) stops the timer; Subscription::detach keeps it running for the life of the timer.

    Source

    run_once

    fn run_once(action: impl Fn() -> () + 'static, interval: Duration, priority: DispatcherPriority) -> Subscription
    

    Runs a method once, after the specified interval.

    Dropping the returned guard (or calling Subscription::dispose) cancels the timer; Subscription::detach keeps it until its only tick.

    Source

    tick

    fn tick(self: &Self, handler: impl Fn(&DispatcherTimer) -> () + 'static) -> Rc<dyn IDisposable>
    

    Occurs when the specified timer interval has elapsed and the timer is enabled.

    Source

    tag

    fn tag(self: &Self) -> Option<BoxedValue>
    

    Any data that the caller wants to pass along with the timer.

    Source

    set_tag

    fn set_tag(self: &Self, value: Option<BoxedValue>)
    

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ErasedDestructor
    • IntoEither

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.