Trait TapMessage

Source
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§

Source

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

Source

fn is_tap_message(&self) -> bool

Checks if this message is a TAP message.

Source

fn get_tap_type(&self) -> Option<String>

Gets the TAP message type from this message.

Source

fn body_as<T: TapMessageBody>(&self) -> Result<T>

Extract a specific message body type from this message.

§Type Parameters
  • T - The type of the body to extract, must implement TapMessageBody
§Returns

The message body if the type matches T, otherwise an error

Source

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

Source

fn message_type(&self) -> &'static str

Get the message type for this message

Source

fn thread_id(&self) -> Option<&str>

Get the thread ID for this message

Source

fn parent_thread_id(&self) -> Option<&str>

Get the parent thread ID for this message

Source

fn message_id(&self) -> &str

Get the message ID for this message

Provided Methods§

Source

fn create_reply<T: TapMessageBody>( &self, body: &T, creator_did: &str, ) -> Result<Message>

Create a reply to this message.

§Type Parameters
  • T - The TAP message body type to create
§Arguments
  • body - The reply message body
  • creator_did - DID of the creator of this reply
§Returns

A new DIDComm message that is properly linked to this message as a reply

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.

Implementations on Foreign Types§

Source§

impl TapMessage for Message

Implementors§