Skip to main content

AdapterRegistry

Struct AdapterRegistry 

Source
pub struct AdapterRegistry<W: Workflow> { /* private fields */ }
Expand description

Runtime registry of MessageAdapters for a single workflow type W.

Adapters are registered at startup via AdapterRegistry::register. After all adapters are registered, call AdapterRegistry::validate_policy to confirm that every format version declared in the workflow’s WorkflowVersionPolicy is covered by at least one adapter.

§Example

use mako_engine::message_adapter::AdapterRegistry;

let mut registry: AdapterRegistry<MyWorkflow> = AdapterRegistry::new();
registry.register(MyFV2025Adapter);
registry.register(MyFV2026Adapter);
registry
    .validate_policy(
        &MyWorkflow::version_policy(),
        &[
            FormatVersion::new("FV2025-10-01"),
            FormatVersion::new("FV2026-10-01"),
        ],
    )
    .expect("all format versions must have a registered adapter");

Implementations§

Source§

impl<W: Workflow> AdapterRegistry<W>

Source

pub fn new() -> Self

Create an empty registry.

Source

pub fn register(&mut self, adapter: impl MessageAdapter<W>)

Register an adapter.

Multiple adapters can be registered. When AdapterRegistry::dispatch is called, the first adapter that returns true from accepts_format_version is used. Register the most specific adapters first.

Source

pub fn dispatch( &self, raw: &dyn Any, fv: &FormatVersion, ) -> Result<W::Command, EngineError>

Dispatch raw to the first adapter that accepts fv.

§Errors

Returns EngineError::Workflow wrapping WorkflowError::other("no adapter registered for format version …") when no registered adapter claims fv.

Propagates the adapter’s own error otherwise.

Source

pub fn validate_policy( &self, policy: &WorkflowVersionPolicy, known_fvs: &[FormatVersion], ) -> Result<(), Vec<FormatVersion>>

Validate that every format version in known_fvs is covered by at least one registered adapter, according to policy.

known_fvs is typically the set of all registered BDEW profiles for the workflow’s message type. In practice, call this at engine startup with the format versions returned by ReleaseRegistry::all_profiles().

§Behaviour per policy
PolicyValidation rule
PinnedAll known_fvs must be covered. A Pinned workflow can be
started under any known FV; every one of them must have an adapter.
ForwardCompatibleSame — all known_fvs must be covered so the
workflow can handle messages in every FV it may encounter.
Explicit(list)Only the explicitly listed FVs must be covered.

Passing an empty known_fvs slice skips all coverage checks and always returns Ok(()).

§Errors

Returns a non-empty list of uncovered format versions. The engine should treat this as a startup error rather than a runtime error.

Source

pub fn len(&self) -> usize

Returns the number of registered adapters.

Source

pub fn is_empty(&self) -> bool

Returns true when no adapters are registered.

Source

pub fn covered_versions<'a>( &self, candidate_fvs: &'a [FormatVersion], ) -> Vec<&'a FormatVersion>

Returns a list of all format versions for which at least one adapter returns true from accepts_format_version, out of the given candidate_fvs set.

Trait Implementations§

Source§

impl<W: Workflow> Debug for AdapterRegistry<W>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<W: Workflow> Default for AdapterRegistry<W>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more