pub trait TapMessage {
// Required methods
fn validate(&self) -> Result<()>;
fn is_tap_message(&self) -> bool;
fn get_tap_type(&self) -> Option<String>;
fn body_as<T: TapMessageBody>(&self) -> Result<T>;
fn get_all_participants(&self) -> Vec<String>;
fn message_type(&self) -> &'static str;
fn thread_id(&self) -> Option<&str>;
fn parent_thread_id(&self) -> Option<&str>;
fn message_id(&self) -> &str;
// Provided method
fn create_reply<T: TapMessageBody>(
&self,
body: &T,
creator_did: &str,
) -> Result<Message> { ... }
}Expand description
Trait for types that can be represented as TAP messages.
This trait provides utility methods for working with DIDComm Messages in the context of the TAP protocol.
Required Methods§
Sourcefn validate(&self) -> Result<()>
fn validate(&self) -> Result<()>
Validates a TAP message.
This method checks if the message meets all the requirements for a valid TAP message, including:
- Having a valid ID
- Having a valid created timestamp
- Having a valid TAP message type
- Having a valid body structure
§Returns
Ok(()) if the message is valid, otherwise an error
Sourcefn is_tap_message(&self) -> bool
fn is_tap_message(&self) -> bool
Checks if this message is a TAP message.
Sourcefn get_tap_type(&self) -> Option<String>
fn get_tap_type(&self) -> Option<String>
Gets the TAP message type from this message.
Sourcefn body_as<T: TapMessageBody>(&self) -> Result<T>
fn body_as<T: TapMessageBody>(&self) -> Result<T>
Sourcefn get_all_participants(&self) -> Vec<String>
fn get_all_participants(&self) -> Vec<String>
Get all participant DIDs from this message.
This includes all DIDs that are involved in the message, such as sender, recipients, and any other participants mentioned in the message body.
§Returns
List of participant DIDs
Sourcefn message_type(&self) -> &'static str
fn message_type(&self) -> &'static str
Get the message type for this message
Sourcefn parent_thread_id(&self) -> Option<&str>
fn parent_thread_id(&self) -> Option<&str>
Get the parent thread ID for this message
Sourcefn message_id(&self) -> &str
fn message_id(&self) -> &str
Get the message ID for this message
Provided Methods§
Sourcefn create_reply<T: TapMessageBody>(
&self,
body: &T,
creator_did: &str,
) -> Result<Message>
fn create_reply<T: TapMessageBody>( &self, body: &T, creator_did: &str, ) -> Result<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.