Struct relm4::factory::FactoryVecDeque
source · pub struct FactoryVecDeque<C: FactoryComponent> { /* private fields */ }
Expand description
A container similar to VecDeque
that can be used to store
data associated with components that implement FactoryComponent
.
To access mutable methods of the factory, create a guard using Self::guard
.
Implementations§
source§impl<C: FactoryComponent> FactoryVecDeque<C>
impl<C: FactoryComponent> FactoryVecDeque<C>
sourcepub fn new(
widget: C::ParentWidget,
parent_sender: &Sender<C::ParentInput>
) -> Self
pub fn new(
widget: C::ParentWidget,
parent_sender: &Sender<C::ParentInput>
) -> Self
Creates a new FactoryVecDeque
.
sourcepub fn guard(&mut self) -> FactoryVecDequeGuard<'_, C>
pub fn guard(&mut self) -> FactoryVecDequeGuard<'_, C>
Provides a FactoryVecDequeGuard
that can be used to edit the factory.
The changes will be rendered on the widgets after the guard goes out of scope.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the FactoryVecDeque
.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the FactoryVecDeque
is empty.
sourcepub fn broadcast(&self, msg: C::Input)where
C::Input: Clone,
pub fn broadcast(&self, msg: C::Input)where
C::Input: Clone,
Send clone of a message to all of the elements.
sourcepub fn get(&self, index: usize) -> Option<&C>
pub fn get(&self, index: usize) -> Option<&C>
Tries to get an immutable reference to the model of one element.
Returns None
if index
is invalid.
sourcepub fn back(&self) -> Option<&C>
pub fn back(&self) -> Option<&C>
Provides a reference to the model of the back element.
Returns None
if the deque is empty.
sourcepub fn front(&self) -> Option<&C>
pub fn front(&self) -> Option<&C>
Provides a reference to the model of the front element.
Returns None
if the deque is empty.
sourcepub const fn widget(&self) -> &C::ParentWidget
pub const fn widget(&self) -> &C::ParentWidget
Returns the widget all components are attached to.
sourcepub fn iter(
&self
) -> impl Iterator<Item = &C> + DoubleEndedIterator + ExactSizeIterator + FusedIterator
pub fn iter(
&self
) -> impl Iterator<Item = &C> + DoubleEndedIterator + ExactSizeIterator + FusedIterator
Returns an iterator over the components.
sourcepub fn from_vec(
component_vec: Vec<C::Init>,
widget: C::ParentWidget,
parent_sender: &Sender<C::ParentInput>
) -> Self
pub fn from_vec(
component_vec: Vec<C::Init>,
widget: C::ParentWidget,
parent_sender: &Sender<C::ParentInput>
) -> Self
Creates a FactoryVecDeque from a Vec
Trait Implementations§
source§impl<C> Clone for FactoryVecDeque<C>where
C: CloneableFactoryComponent + FactoryComponent,
impl<C> Clone for FactoryVecDeque<C>where
C: CloneableFactoryComponent + FactoryComponent,
Implements the Clone Trait for FactoryVecDeque<C>
where C is Cloneable