pub struct CraftingQueue { /* private fields */ }Expand description
Ordered pending job queue with a maximum of 8 slots.
Implementations§
Source§impl CraftingQueue
impl CraftingQueue
pub fn new() -> Self
Sourcepub fn has_capacity(&self) -> bool
pub fn has_capacity(&self) -> bool
Whether the queue has room for another job.
pub fn is_empty(&self) -> bool
Sourcepub fn enqueue(
&mut self,
recipe_id: impl Into<String>,
ingredients_consumed: Vec<(String, u32)>,
started_at: f32,
duration: f32,
quantity: u32,
owner_id: impl Into<String>,
) -> Option<u64>
pub fn enqueue( &mut self, recipe_id: impl Into<String>, ingredients_consumed: Vec<(String, u32)>, started_at: f32, duration: f32, quantity: u32, owner_id: impl Into<String>, ) -> Option<u64>
Enqueue a new job, returning its id or None if the queue is full.
Sourcepub fn front(&self) -> Option<&CraftingJob>
pub fn front(&self) -> Option<&CraftingJob>
Peek at the front job without removing it.
Sourcepub fn dequeue(&mut self) -> Option<CraftingJob>
pub fn dequeue(&mut self) -> Option<CraftingJob>
Dequeue the front job.
Sourcepub fn cancel(&mut self, job_id: u64) -> Option<CraftingJob>
pub fn cancel(&mut self, job_id: u64) -> Option<CraftingJob>
Remove a job by id (e.g. on cancellation).
Sourcepub fn all_jobs(&self) -> &[CraftingJob]
pub fn all_jobs(&self) -> &[CraftingJob]
All jobs currently in the queue.
Trait Implementations§
Source§impl Clone for CraftingQueue
impl Clone for CraftingQueue
Source§fn clone(&self) -> CraftingQueue
fn clone(&self) -> CraftingQueue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CraftingQueue
impl Debug for CraftingQueue
Auto Trait Implementations§
impl Freeze for CraftingQueue
impl RefUnwindSafe for CraftingQueue
impl Send for CraftingQueue
impl Sync for CraftingQueue
impl Unpin for CraftingQueue
impl UnsafeUnpin for CraftingQueue
impl UnwindSafe for CraftingQueue
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.