Debounce

Struct Debounce 

Source
pub struct Debounce<T> { /* private fields */ }
Expand description

Debounce struct enables calling the provided closure after a specified delay. The delay is reset if another call is made before the delay duration has passed. It holds an Option for a sender which is used to send messages to the worker thread. It also holds an Option for a JoinHandle for the worker thread. The debounce_config stores the closure and delay information.

§Fields

  • sender - An Option for a sender which is used to send messages to the worker thread.
  • thread - An Option for a JoinHandle for the worker thread.
  • debounce_config - Stores the closure and delay information.

Implementations§

Source§

impl<T> Debounce<T>

Source

pub fn call(&self, param: T)

Method call sends a message with a parameter to the worker thread. This causes the delay timer to reset in the worker thread.

§Arguments
  • param - The parameter to send to the worker thread. This will be used as the argument for the closure when the delay has passed.
Source

pub fn terminate(&self)

Method terminate sends a None message to the worker thread, causing it to exit the loop and end the execution.

Trait Implementations§

Source§

impl<T> Drop for Debounce<T>

Source§

fn drop(&mut self)

The Drop trait implementation for Debounce. On drop, it terminates the worker thread and logs a message with the memory address of the Debounce instance.

Auto Trait Implementations§

§

impl<T> Freeze for Debounce<T>

§

impl<T> !RefUnwindSafe for Debounce<T>

§

impl<T> Send for Debounce<T>
where T: Send,

§

impl<T> Sync for Debounce<T>
where T: Send,

§

impl<T> Unpin for Debounce<T>

§

impl<T> !UnwindSafe for Debounce<T>

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, 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.