pub trait MaEndpoint: Send + Sync {
// Required methods
fn id(&self) -> String;
fn service(&mut self, protocol: &str) -> Inbox<Message>;
fn services(&self) -> Vec<String>;
fn send_to<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
target: &'life1 str,
protocol: &'life2 str,
message: &'life3 Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn connect_outbox<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
doc: &'life1 Document,
endpoint_id: &'life2 str,
did: &'life3 str,
protocol: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<Outbox>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
// Provided methods
fn services_json(&self) -> Value { ... }
fn ma_extension(&self) -> MaExtension { ... }
fn outbox<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
resolver: &'life1 dyn DidDocumentResolver,
did: &'life2 str,
protocol: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Outbox>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
target: &'life1 str,
message: &'life2 Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Shared interface for ma transport endpoints.
Each implementation provides inbox/outbox messaging and advertises its registered services for DID documents.
Required Methods§
Sourcefn service(&mut self, protocol: &str) -> Inbox<Message>
fn service(&mut self, protocol: &str) -> Inbox<Message>
Register a service protocol and return an Inbox for receiving messages.
Implementations should ensure the service is reachable for inbound delivery once it has been registered, so callers do not need a second explicit “listen” step in the common case.
Sourcefn services(&self) -> Vec<String>
fn services(&self) -> Vec<String>
Return service strings for all registered protocols.
Each entry is suitable for inclusion in a DID document’s ma.services array.
Sourcefn send_to<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
target: &'life1 str,
protocol: &'life2 str,
message: &'life3 Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn send_to<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
target: &'life1 str,
protocol: &'life2 str,
message: &'life3 Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Fire-and-forget to a target on a specific protocol.
Sourcefn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gracefully shut down the endpoint, closing all cached connections.
Sourcefn connect_outbox<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
doc: &'life1 Document,
endpoint_id: &'life2 str,
did: &'life3 str,
protocol: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<Outbox>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn connect_outbox<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
doc: &'life1 Document,
endpoint_id: &'life2 str,
did: &'life3 str,
protocol: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<Outbox>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Open a transport-level outbox given a pre-resolved document and endpoint ID.
Implementors use doc for transport-specific routing hints (e.g. relay URLs)
and endpoint_id as the peer address on their transport layer.
Provided Methods§
Sourcefn services_json(&self) -> Value
fn services_json(&self) -> Value
Return service strings as a JSON array value.
Sourcefn ma_extension(&self) -> MaExtension
fn ma_extension(&self) -> MaExtension
Build a crate::MaExtension pre-populated with this endpoint’s
service strings.
Use this as the starting point when constructing the ma: field for a
DID document. Chain additional builder methods on the returned value
before passing it to crate::config::SecretBundle::build_document or
crate::Document::set_ma_extension:
let ma = endpoint.ma_extension().kind("world");
let document = bundle.build_document(ma)?;Sourcefn outbox<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
resolver: &'life1 dyn DidDocumentResolver,
did: &'life2 str,
protocol: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Outbox>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn outbox<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
resolver: &'life1 dyn DidDocumentResolver,
did: &'life2 str,
protocol: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Outbox>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Open a transport-agnostic outbox to a remote DID and protocol.
Resolves the DID document, checks ma.services for the requested
protocol, and delegates the actual transport connection to
Self::connect_outbox. Override this only for non-standard resolution.
Sourcefn send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
target: &'life1 str,
message: &'life2 Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
target: &'life1 str,
message: &'life2 Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fire-and-forget to a target on the default inbox protocol.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".