Queue

Struct Queue 

Source
pub struct Queue<T>
where T: SimObject,
{ /* private fields */ }
Expand description

A generic queue for simulation objects.

Implementations§

Source§

impl<T> Queue<T>
where T: SimObject,

Source

pub fn new( parent: &Rc<Entity>, name: &str, capacity: Option<usize>, ) -> Result<Self, SimError>

Create a new queue.

Returns a [SimError] if capacity is Some(0).

Source

pub fn len(&self) -> usize

Return the current queue length.

Source

pub fn is_empty(&self) -> bool

Return whether the queue is empty.

Source

pub fn is_full(&self) -> bool

Return whether the queue is full.

Source

pub fn values(&self) -> Vec<T>

Return a snapshot of the queue contents by copying all values.

Source

pub fn changed_event(&self) -> Repeated<()>

Return an event that fires whenever the queue contents change.

Source

pub async fn push(&self, value: T) -> SimResult

Push a value into the queue, waiting until there is space if required.

Source

pub fn pop_front(&self) -> Option<T>

Pop the oldest value from the queue.

Source

pub fn remove_where<F>(&self, predicate: F) -> Option<T>
where F: FnMut(&T) -> bool,

Remove the first value matching the predicate.

Trait Implementations§

Source§

impl<T> Debug for Queue<T>
where T: SimObject,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Display for Queue<T>
where T: SimObject,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for Queue<T>

§

impl<T> !RefUnwindSafe for Queue<T>

§

impl<T> !Send for Queue<T>

§

impl<T> !Sync for Queue<T>

§

impl<T> Unpin for Queue<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Queue<T>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V