[−][src]Trait kompact::component::AbstractComponent
An object-safe trait that exposes most of functionality of a Component
that isn't
dependent on a particular ComponentDefinition
.
Useful if you want to reduce code bloat by removing the generic parameter from Component<CD>
.
See also: ActorRefFactory
and CoreContainer
, which this trait inherits.
Required methods
fn dyn_definition_mut(
&mut self
) -> &mut dyn DynamicComponentDefinition<Message = Self::Message>
&mut self
) -> &mut dyn DynamicComponentDefinition<Message = Self::Message>
Returns a mutable reference to the underlying component definition as a
DynamicComponentDefinition
trait object.
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.
fn lock_dyn_definition(
&self
) -> Result<DynamicComponentDefinitionMutexGuard<'_, Self::Message>, LockPoisoned>
&self
) -> Result<DynamicComponentDefinitionMutexGuard<'_, Self::Message>, LockPoisoned>
Locks the component definition mutex and returns a guard that can be dereferenced to
access a DynamicComponentDefinition
trait object.
fn as_any(&self) -> &dyn Any
Implementations
impl<M: MessageBounds> dyn AbstractComponent<Message = M>
[src]
pub fn on_dyn_definition<F, R>(&self, f: F) -> R where
F: FnOnce(&mut dyn DynamicComponentDefinition<Message = M>) -> R,
[src]
F: FnOnce(&mut dyn DynamicComponentDefinition<Message = M>) -> R,
Execute a function on the underlying component definition
and return the result. The component definition will be accessed as a
DynamicComponentDefinition
trait object.
This method will attempt to lock the mutex, and then apply f
to the component definition
inside the guard.
This method wraps the mutex guard in an additional allocation. Prefer
Component::on_definition
where possible.
Implementors
impl<C> AbstractComponent for Component<C> where
C: ComponentTraits + ComponentLifecycle,
[src]
C: ComponentTraits + ComponentLifecycle,
fn dyn_definition_mut(
&mut self
) -> &mut dyn DynamicComponentDefinition<Message = Self::Message>
[src]
&mut self
) -> &mut dyn DynamicComponentDefinition<Message = Self::Message>
fn lock_dyn_definition(
&self
) -> Result<DynamicComponentDefinitionMutexGuard<'_, Self::Message>, LockPoisoned>
[src]
&self
) -> Result<DynamicComponentDefinitionMutexGuard<'_, Self::Message>, LockPoisoned>