pub struct Events<E> { /* private fields */ }Expand description
A double-buffered event queue: events stay readable for two frames.
Implementations§
Source§impl<E> Events<E>
impl<E> Events<E>
Sourcepub fn send(&mut self, event: E)
pub fn send(&mut self, event: E)
Queue an event. It becomes visible to readers immediately and stays
readable until the second update after this one.
Sourcepub fn update(&mut self)
pub fn update(&mut self)
Advance one frame: retire the older buffer and start a fresh newest one. Events older than two cycles are dropped.
Sourcepub fn read(&self, cursor: &mut EventCursor) -> impl Iterator<Item = &E>
pub fn read(&self, cursor: &mut EventCursor) -> impl Iterator<Item = &E>
Read every buffered event the cursor has not yet seen, in send order, and advance the cursor past them.
Lazy: a drain costs no allocation, which matters because every event reader does this every frame. The cursor advances here rather than as the iterator is consumed, so a caller that reads only part of the run still ends up past all of it – the same thing a returned collection did, and the only behaviour that makes “every reader sees every event exactly once” hold for a partial read.
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for Events<E>
impl<E> RefUnwindSafe for Events<E>
impl<E> Send for Events<E>
impl<E> Sync for Events<E>
impl<E> Unpin for Events<E>
impl<E> UnsafeUnpin for Events<E>
impl<E> UnwindSafe for Events<E>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().