Skip to main content

ModuleAdapter

Trait ModuleAdapter 

Source
pub trait ModuleAdapter<External, Internal>: Send + Sync
where External: Send + 'static, Internal: Send + 'static,
{ type Error: Error + Send + Sync; // Required methods fn to_internal<'life0, 'async_trait>( &'life0 self, external: External, ) -> Pin<Box<dyn Future<Output = Result<Internal, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn not_implemented(&self, method: &str) -> Self::Error; // Provided methods fn source_module() -> &'static str where Self: Sized { ... } fn target_module() -> &'static str where Self: Sized { ... } fn to_external<'life0, 'async_trait>( &'life0 self, _internal: Internal, ) -> Pin<Box<dyn Future<Output = Result<External, Self::Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } }
Expand description

Bidirectional adapter between an external module’s type and this module’s type.

  • External — the foreign type (from another bounded context).
  • Internal — this module’s representation.

Implement source_module() and target_module() to identify the bounded contexts involved. These are used for logging and cross-context tracing.

Required Associated Types§

Source

type Error: Error + Send + Sync

The error type for failed conversions.

Required Methods§

Source

fn to_internal<'life0, 'async_trait>( &'life0 self, external: External, ) -> Pin<Box<dyn Future<Output = Result<Internal, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Convert an external type into this module’s internal representation.

Source

fn not_implemented(&self, method: &str) -> Self::Error

Provided Methods§

Source

fn source_module() -> &'static str
where Self: Sized,

The bounded context that owns External (the source).

Example: "sapiens" when the external type comes from the Sapiens module.

Source

fn target_module() -> &'static str
where Self: Sized,

The bounded context that owns Internal (the target / this module).

Example: "corpus" when this adapter lives in the Corpus module.

Source

fn to_external<'life0, 'async_trait>( &'life0 self, _internal: Internal, ) -> Pin<Box<dyn Future<Output = Result<External, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Convert this module’s internal type into the external format (optional).

Override when the module publishes events consumed by other modules.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§