pub struct State { /* private fields */ }
Expand description
State of a simulation holding all queues and arbitrary values in a store value.
Implementations
sourceimpl State
impl State
sourcepub fn insert<V: 'static>(&mut self, value: V) -> Key<V>
pub fn insert<V: 'static>(&mut self, value: V) -> Key<V>
Inserts an arbitrary value to the value store. Learn more in the documentation for Key
.
sourcepub fn remove<V: 'static>(&mut self, key: Key<V>) -> Option<V>
pub fn remove<V: 'static>(&mut self, key: Key<V>) -> Option<V>
Removes a value of type V
from the value store. Learn more in the documentation for Key
.
sourcepub fn get<V: 'static>(&self, key: Key<V>) -> Option<&V>
pub fn get<V: 'static>(&self, key: Key<V>) -> Option<&V>
Gets a immutable reference to a value of a type V
from the value store.
Learn more in the documentation for Key
.
sourcepub fn get_mut<V: 'static>(&mut self, key: Key<V>) -> Option<&mut V>
pub fn get_mut<V: 'static>(&mut self, key: Key<V>) -> Option<&mut V>
Gets a mutable reference to a value of a type V
from the value store.
Learn more in the documentation for Key
.
sourcepub fn add_queue<Q: Queue + 'static>(&mut self, queue: Q) -> QueueId<Q>
pub fn add_queue<Q: Queue + 'static>(&mut self, queue: Q) -> QueueId<Q>
Creates a new unbounded queue, returning its ID.
sourcepub fn send<Q: Queue + 'static>(
&mut self,
queue: QueueId<Q>,
value: Q::Item
) -> Result<(), PushError>
pub fn send<Q: Queue + 'static>(
&mut self,
queue: QueueId<Q>,
value: Q::Item
) -> Result<(), PushError>
Sends value
to the queue
. This is a shorthand for queue_mut(queue).push(value)
.
Errors
It returns an error if the queue is full.
sourcepub fn recv<Q: Queue + 'static>(&mut self, queue: QueueId<Q>) -> Option<Q::Item>
pub fn recv<Q: Queue + 'static>(&mut self, queue: QueueId<Q>) -> Option<Q::Item>
Pops the first value from the queue
. It returns None
if the queue is empty.
This is a shorthand for queue_mut(queue).pop(value)
.
sourcepub fn len<Q: Queue + 'static>(&self, queue: QueueId<Q>) -> usize
pub fn len<Q: Queue + 'static>(&self, queue: QueueId<Q>) -> usize
Checks the number of elements in the queue.
This is a shorthand for queue(queue).len()
.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for State
impl !Send for State
impl !Sync for State
impl Unpin for State
impl !UnwindSafe for State
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more