pub struct Component<CD>where
CD: ComponentTraits,{ /* private fields */ }Expand description
A concrete component instance
The component class itself is application agnostic, but it contains the application specific ComponentDefinition.
Implementations§
Source§impl<CD> Component<CD>where
CD: ComponentTraits,
impl<CD> Component<CD>where
CD: ComponentTraits,
Sourcepub fn definition_mut(&mut self) -> &mut CD
pub fn definition_mut(&mut self) -> &mut CD
Returns a mutable reference to the underlying component definition.
This can only be done if you have a reference to the component instance that isn’t hidden behind an Arc. For example, after the system shuts down and your code holds on to the last reference to a component you can use get_mut or try_unwrap.
Sourcepub fn on_definition<T, F>(&self, f: F) -> T
pub fn on_definition<T, F>(&self, f: F) -> T
Execute a function on the underlying ComponentDefinition and return the result
This method will attempt to lock the mutex, and then apply f to the component definition
inside the guard.
Sourcepub fn logger(&self) -> &Logger<Arc<Fuse<Async>>>
pub fn logger(&self) -> &Logger<Arc<Fuse<Async>>>
Returns a reference to this component’s logger
Sourcepub fn is_destroyed(&self) -> bool
pub fn is_destroyed(&self) -> bool
Returns true if the component is marked as destroyed.
Sourcepub fn wait_ended(&self)
pub fn wait_ended(&self)
Wait synchronously for this component be either destroyed or faulty
This component blocks the current thread and hot-waits for the component to become either faulty or destroyed. It is meant mostly for testing and not recommended in production.
Sourcepub fn set_recovery_function<F>(&self, f: F)
pub fn set_recovery_function<F>(&self, f: F)
Set the recovery function for this component
See RecoveryHandler for more information.
Trait Implementations§
Source§impl<C> AbstractComponent for Component<C>where
C: ComponentTraits + ComponentLifecycle,
impl<C> AbstractComponent for Component<C>where
C: ComponentTraits + ComponentLifecycle,
Source§fn dyn_definition_mut(
&mut self,
) -> &mut dyn DynamicComponentDefinition<Message = <Component<C> as MsgQueueContainer>::Message>
fn dyn_definition_mut( &mut self, ) -> &mut dyn DynamicComponentDefinition<Message = <Component<C> as MsgQueueContainer>::Message>
DynamicComponentDefinition trait object. Read moreSource§fn lock_dyn_definition(
&self,
) -> Result<OwningRefMut<Box<dyn Erased + '_>, dyn DynamicComponentDefinition<Message = <Component<C> as MsgQueueContainer>::Message>>, LockPoisoned>
fn lock_dyn_definition( &self, ) -> Result<OwningRefMut<Box<dyn Erased + '_>, dyn DynamicComponentDefinition<Message = <Component<C> as MsgQueueContainer>::Message>>, LockPoisoned>
DynamicComponentDefinition trait object.