Skip to main content

ConcreteComponent

Trait ConcreteComponent 

Source
pub trait ConcreteComponent: ErasedComponent + Sized {
    type Config: Any + 'static;
    type Error: Error + Send + Sync + 'static;

    const TYPE_NAME: &'static str;
    const PACKAGE: ComponentPackage = ComponentPackage::Application;
    const DEPENDENCIES: &'static [DependencyDecl] = _;

    // Required methods
    fn new(config: &Self::Config) -> Result<Self, Self::Error>;
    fn serialize(&self) -> Vec<u8> ;
    fn restore(bytes: &[u8]) -> Result<Self, RestoreError>;
}
Expand description

Polymorphism contract. Implementing this trait IS the registration mechanism — no global registry, no macro required. Serialized state must be self-contained so restore reconstructs without the original Config.

Required Associated Constants§

Source

const TYPE_NAME: &'static str

Stable identifier. Convention: <crate>::<TypeName>.

Provided Associated Constants§

Source

const PACKAGE: ComponentPackage = ComponentPackage::Application

Origin tag; defaults to Application.

Source

const DEPENDENCIES: &'static [DependencyDecl] = _

Sibling components this depends on. Populated by the bb::Concrete derive from #[bb::depends(...)].

Required Associated Types§

Source

type Config: Any + 'static

Per-deployment config. Use () for stateless concretes.

Source

type Error: Error + Send + Sync + 'static

Error from Self::new; use Infallible if construction can’t fail.

Required Methods§

Source

fn new(config: &Self::Config) -> Result<Self, Self::Error>

Construct from &Self::Config. Install calls this once per slot.

Source

fn serialize(&self) -> Vec<u8>

Serialize state to bytes, including config-derived fields.

Source

fn restore(bytes: &[u8]) -> Result<Self, RestoreError>

Reconstruct from serialize output.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§