Skip to main content

RuntimeEventBatch

Struct RuntimeEventBatch 

Source
pub struct RuntimeEventBatch<'a> { /* private fields */ }
Expand description

Batch of runtime events borrowed from runtime-owned storage.

A batch borrows the RuntimeHandle it came from, so the next drain is a compile error while the batch lives, and an event read out of a batch borrows the batch. Take RuntimeEventRef::to_owned for a value that outlives either.

Implementations§

Source§

impl<'a> RuntimeEventBatch<'a>

Source

pub fn len(&self) -> usize

Returns how many events this batch reports.

Source

pub fn is_empty(&self) -> bool

Reports whether this batch has no events.

Source

pub fn remaining(&self) -> usize

Returns how many events stayed queued after this batch. A nonzero count means another drain reports more events.

Source

pub fn iter(&self) -> impl Iterator<Item = RuntimeEventRef<'_>>

Walks this batch’s events in queue order.

Each event borrows this batch, so safe code cannot read one after the batch is gone:

let mut runtime = RuntimeHandle::with_options(&RuntimeOptions::default()).unwrap();
let batch = runtime.drain_events(0).unwrap();
let events = batch.iter().collect::<Vec<_>>();
drop(batch);
let _ = events.first().map(|event| event.message_bytes());

Trait Implementations§

Source§

impl Debug for RuntimeEventBatch<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RuntimeEventBatch<'a>

§

impl<'a> RefUnwindSafe for RuntimeEventBatch<'a>

§

impl<'a> !Send for RuntimeEventBatch<'a>

§

impl<'a> !Sync for RuntimeEventBatch<'a>

§

impl<'a> Unpin for RuntimeEventBatch<'a>

§

impl<'a> UnsafeUnpin for RuntimeEventBatch<'a>

§

impl<'a> UnwindSafe for RuntimeEventBatch<'a>

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.