pub trait ModuleAdapter<External, Internal>: Send + Sync{
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§
Required Methods§
Sourcefn 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 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.
fn not_implemented(&self, method: &str) -> Self::Error
Provided Methods§
Sourcefn source_module() -> &'static strwhere
Self: Sized,
fn source_module() -> &'static strwhere
Self: Sized,
The bounded context that owns External (the source).
Example: "sapiens" when the external type comes from the Sapiens module.
Sourcefn target_module() -> &'static strwhere
Self: Sized,
fn target_module() -> &'static strwhere
Self: Sized,
The bounded context that owns Internal (the target / this module).
Example: "corpus" when this adapter lives in the Corpus module.
Sourcefn 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,
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".