pub trait Adapter:
Send
+ Sync
+ 'static {
// Required methods
fn id(&self) -> &AdapterId;
fn run<'async_trait>(
self: Arc<Self>,
engine: Arc<Engine>,
shutdown: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<(), AdapterError>> + Send + 'async_trait>>
where Self: 'async_trait;
}Expand description
A protocol plugin that owns its I/O loop and maps native frames onto envelopes.
The engine is the only shared state. Adapters never call each other.
Each one creates the mpsc channel it hands to
Engine::subscribe and reads
the matching receiver. Call
Engine::drop_adapter on
the way out, or subscriptions keep matching and silently discarding
messages.
Required Methods§
Sourcefn id(&self) -> &AdapterId
fn id(&self) -> &AdapterId
Stable id for this adapter instance.
The host logs it. Bridging adapters also stamp
oag.origin_adapter with it so they can refuse their own echo.
Sourcefn run<'async_trait>(
self: Arc<Self>,
engine: Arc<Engine>,
shutdown: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<(), AdapterError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn run<'async_trait>(
self: Arc<Self>,
engine: Arc<Engine>,
shutdown: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<(), AdapterError>> + Send + 'async_trait>>where
Self: 'async_trait,
Runs until shutdown is cancelled, or until this adapter cannot
continue.
This is the whole lifetime: accept or connect, read frames,
publish envelopes, and return. Subscribe only after the
transport is up, so deliveries are not queued with nowhere to
go. Observe shutdown in the same loop that reads the
transport.
§Errors
Returning Err is fatal for this adapter only. The host logs
it and does not restart run. Ok is the shutdown path.