pub struct EventBufferManager<const N: usize> { /* private fields */ }
Expand description
An ergonomic wrapper over fallibly writing to fixed-size event buffers.
As FixedSizeEventBuffer
has a fixed capacity, callers have to handle the scenario where they attempt to push an
event into the event buffer but the buffer has no more capacity. This generally involves having to swap it with a
new buffer, as well as holding the event around until they acquire the new buffer.
EventBufferManager
provides a simple, ergonomic wrapper over a basic pattern of treating the current buffer as an
optional value, and handling the logic of ensuring we have a buffer to write into only when actually attempting a
write, rather than always holding on to one.
Implementations§
Source§impl<const N: usize> EventBufferManager<N>
impl<const N: usize> EventBufferManager<N>
Sourcepub fn try_push(&mut self, event: Event) -> Option<FixedSizeEventBuffer<N>>
pub fn try_push(&mut self, event: Event) -> Option<FixedSizeEventBuffer<N>>
Attempts to push an event into the current event buffer.
If the event buffer is full, it is replaced with a new event buffer before pushing the event, and Some(buffer)
is returned containing the old event buffer. Otherwise, None
is returned.
Sourcepub fn consume(&mut self) -> Option<FixedSizeEventBuffer<N>>
pub fn consume(&mut self) -> Option<FixedSizeEventBuffer<N>>
Consumes the current event buffer, if one exists.
Trait Implementations§
Source§impl<const N: usize> Default for EventBufferManager<N>
impl<const N: usize> Default for EventBufferManager<N>
Source§fn default() -> EventBufferManager<N>
fn default() -> EventBufferManager<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for EventBufferManager<N>
impl<const N: usize> !RefUnwindSafe for EventBufferManager<N>
impl<const N: usize> Send for EventBufferManager<N>
impl<const N: usize> Sync for EventBufferManager<N>
impl<const N: usize> Unpin for EventBufferManager<N>
impl<const N: usize> !UnwindSafe for EventBufferManager<N>
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> 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
Source§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
Tracked
wrapper. Read more§fn in_current_allocation_group(self) -> Tracked<Self>
fn in_current_allocation_group(self) -> Tracked<Self>
Tracked
wrapper. Read more