Skip to main content

AnyComponent

Trait AnyComponent 

Source
pub trait AnyComponent:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &'static str;
    fn as_any_arc(&self) -> Arc<dyn Any + Send + Sync> ;
    fn start(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<(), AnyComponentError>> + Send + '_>>;
    fn stop(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<(), AnyComponentError>> + Send + '_>>;
    fn health(&self) -> Pin<Box<dyn Future<Output = HealthStatus> + Send + '_>>;
    fn pre_replace(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<(), AnyComponentError>> + Send + '_>>;
    fn post_replace(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<(), AnyComponentError>> + Send + '_>>;
}
Expand description

Object-safe view of a Component instance, used by the registry to store and drive components of heterogeneous types uniformly.

Required Methods§

Source

fn name(&self) -> &'static str

Stable name of the underlying Component kind.

Source

fn as_any_arc(&self) -> Arc<dyn Any + Send + Sync>

Underlying concrete type, used by ComponentRegistry::get to downcast back to a concrete Arc<C>. Returns a type-erased Arc<dyn Any> clone of the typed instance.

Source

fn start( &self, ) -> Pin<Box<dyn Future<Output = Result<(), AnyComponentError>> + Send + '_>>

Begin serving. See Component::start.

Source

fn stop( &self, ) -> Pin<Box<dyn Future<Output = Result<(), AnyComponentError>> + Send + '_>>

Stop serving. See Component::stop.

Source

fn health(&self) -> Pin<Box<dyn Future<Output = HealthStatus> + Send + '_>>

Health probe. See Component::health.

Source

fn pre_replace( &self, ) -> Pin<Box<dyn Future<Output = Result<(), AnyComponentError>> + Send + '_>>

Called before this component is replaced. See Component::pre_replace_hook.

Source

fn post_replace( &self, ) -> Pin<Box<dyn Future<Output = Result<(), AnyComponentError>> + Send + '_>>

Called after this component has been replaced. See Component::post_replace_hook.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§