[−][src]Struct rjdebounce::Bouncer
Fields
delay: Duration
Implementations
impl<T> Bouncer<T>
[src]
pub fn new(delay: Duration) -> Self
[src]
Creates a new bouncer object
Example Usage:
use rjdebounce::Bouncer; let mut bouncer = Bouncer::new(Duration::from_secs(1)); let result = bouncer.debounce(|| { return 5 + 5; }) assert_eq!(result.is_some(), true); assert_eq!(result.unwrap(), 10);
pub fn with_func(self, func: fn() -> T) -> Self
[src]
Binds a function internally to call using the execute() function.
Example Usage:
use rjdebounce::Bouncer; let mut bouncer = Bouncer::new(Duration::from_secs(1)).with_func(|| 5 + 5); let result1 = bouncer.get_result(); bouncer.execute(); let result2 = bouncer.get_result(); assert_equal!(result.is_some(), false); assert_equal!(result.is_some(), true);
pub fn execute(&mut self)
[src]
If Bouncer is created with_func(), call this function to execute the provided function.
pub fn get_result(&mut self) -> Option<&mut T>
[src]
If Bouncer is created with_func(), call this function in order to obtain a reference to the result.
pub fn debounce(&mut self, func: fn() -> T) -> Option<T>
[src]
debounces provided function only running if it has never been run, or, if the elasped time has past since the function was last run.
pub fn reset(&mut self)
[src]
Resets the last_run property to None. Makes the bouncer act as if it never ran a function.
Auto Trait Implementations
impl<T> RefUnwindSafe for Bouncer<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Bouncer<T> where
T: Send,
T: Send,
impl<T> Sync for Bouncer<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Bouncer<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Bouncer<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,