pub struct BounceFilter { /* private fields */ }Expand description
Holds the minimal state required for bounce filtering decisions.
This struct only stores the timestamp (in microseconds) of the last passed event for each key code and value combination.
Implementations§
Source§impl BounceFilter
impl BounceFilter
Sourcepub fn new(ring_buffer_size: usize) -> Self
pub fn new(ring_buffer_size: usize) -> Self
Creates a new BounceFilter with a specified ring buffer size.
The ring buffer stores the last ring_buffer_size passed events for debugging.
If ring_buffer_size is 0, the buffer is not allocated and has no overhead.
Sourcepub fn check_event(
&mut self,
event: &input_event,
debounce_time: Duration,
skip_debounce: bool,
) -> EventInfo
pub fn check_event( &mut self, event: &input_event, debounce_time: Duration, skip_debounce: bool, ) -> EventInfo
Checks an incoming event against the debounce filter state.
Determines if the event is a bounce based on the debounce_time_us
and the timestamp of the last passed event of the same type.
Updates the internal state (last_event_us) only if the event passes.
Also tracks the overall first and last event timestamps.
§Arguments
event: The input event to check.debounce_time: The debounce threshold as aDuration.
§Returns
An EventInfo struct containing the result of the check and relevant timestamps.
Sourcepub fn get_runtime_us(&self) -> Option<u64>
pub fn get_runtime_us(&self) -> Option<u64>
Returns the total duration based on the first and last event timestamps seen.
Returns None if no events were processed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BounceFilter
impl RefUnwindSafe for BounceFilter
impl Send for BounceFilter
impl Sync for BounceFilter
impl Unpin for BounceFilter
impl UnsafeUnpin for BounceFilter
impl UnwindSafe for BounceFilter
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request