pub trait TapMessageBody:
Serialize
+ DeserializeOwned
+ Send
+ Sync {
// Required methods
fn message_type() -> &'static str
where Self: Sized;
fn validate(&self) -> Result<()>;
// Provided methods
fn to_didcomm(&self, from: &str) -> Result<PlainMessage> { ... }
fn to_didcomm_with_route<'a, I>(
&self,
from: &str,
to: I,
) -> Result<PlainMessage>
where I: IntoIterator<Item = &'a str> { ... }
fn from_didcomm(message: &PlainMessage) -> Result<Self>
where Self: Sized { ... }
}Expand description
A trait for TAP message body types that can be serialized to and deserialized from DIDComm messages.
Required Methods§
Sourcefn message_type() -> &'static strwhere
Self: Sized,
fn message_type() -> &'static strwhere
Self: Sized,
Get the message type string for this body type.
Provided Methods§
Sourcefn to_didcomm(&self, from: &str) -> Result<PlainMessage>
fn to_didcomm(&self, from: &str) -> Result<PlainMessage>
Convert this body to a DIDComm message.
Sourcefn to_didcomm_with_route<'a, I>(
&self,
from: &str,
to: I,
) -> Result<PlainMessage>where
I: IntoIterator<Item = &'a str>,
fn to_didcomm_with_route<'a, I>(
&self,
from: &str,
to: I,
) -> Result<PlainMessage>where
I: IntoIterator<Item = &'a str>,
Convert this body to a DIDComm message with a custom routing path.
This method allows specifying an explicit list of recipient DIDs, overriding the automatic extraction of participants from the message body.
§Arguments
from- The sender DIDto- An iterator of recipient DIDs
§Returns
A new DIDComm message with the specified routing
Sourcefn from_didcomm(message: &PlainMessage) -> Result<Self>where
Self: Sized,
fn from_didcomm(message: &PlainMessage) -> Result<Self>where
Self: Sized,
Extract this body type from a DIDComm message.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.