Struct Queue

Source
pub struct Queue<T> { /* private fields */ }
Expand description

FIFO queue with async pop.

Implementations§

Source§

impl<T> Queue<T>

Source

pub fn new() -> Self

Creates new queue with unbounded capacity.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates new queue with given capacity.

capacity must be greater than 0 - it’ll panic otherwise.

Source

pub fn push(&self, element: T)

Pushes element into the queue.

If queue is full it will push out the last (oldest) element out of the queue.

Source

pub fn pop(&self) -> Pop<'_, T>

Pops (asynchronously) element off the queue.

It means that if queue is currently empty await will wait till element is pushed into the queue.

Source

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

Pops element off the queue.

Returns None if queue is currently empty.

Source

pub fn len(&self) -> usize

Returns count of elements currently in the queue.

Source

pub fn is_empty(&self) -> bool

Returns true if queue is currently empty.

Source

pub fn is_full(&self) -> bool

Returns true if queue is currently full.

Trait Implementations§

Source§

impl<T> Default for Queue<T>

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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.