#[derive(TapMessage)]
{
// Attributes available to this derive:
#[tap]
}
Expand description
Procedural derive macro for implementing TapMessage, MessageContext, and optionally TapMessageBody traits.
§Usage
§Basic Usage (TapMessage + MessageContext only)
ⓘ
use tap_msg::TapMessage;
use tap_msg::message::{Party, Agent};
use tap_caip::AssetId;
#[derive(TapMessage)]
pub struct Transfer {
#[tap(participant)]
pub originator: Party,
#[tap(participant)]
pub beneficiary: Option<Party>,
#[tap(participant_list)]
pub agents: Vec<Agent>,
#[tap(transaction_id)]
pub transaction_id: String,
// regular fields don't need attributes
pub amount: String,
pub asset: AssetId,
}§Full Usage (includes TapMessageBody with auto-generated to_didcomm)
ⓘ
use tap_msg::TapMessage;
use tap_msg::message::{Party, Agent};
use serde::{Serialize, Deserialize};
#[derive(Debug, Clone, Serialize, Deserialize, TapMessage)]
#[tap(message_type = "https://tap.rsvp/schema/1.0#Transfer", initiator, authorizable, transactable)]
pub struct Transfer {
#[tap(participant)]
pub originator: Party,
#[tap(participant)]
pub beneficiary: Option<Party>,
#[tap(participant_list)]
pub agents: Vec<Agent>,
#[tap(transaction_id)]
pub transaction_id: String,
pub amount: String,
}
// TapMessageBody is automatically implemented with:
// - message_type() returning the specified string
// - validate() with basic validation (can be overridden)
// - to_didcomm() with automatic participant extraction and message construction
// - Authorizable trait (if authorizable attribute is present)
// - Transaction trait (if transactable attribute is present)§Supported Attributes
§Struct-level Attributes
#[tap(message_type = "url")]- TAP message type URL (enables TapMessageBody generation)#[tap(initiator)]- Marks this as a conversation-initiating message#[tap(authorizable)]- Auto-generates Authorizable trait implementation#[tap(transactable)]- Auto-generates Transaction trait implementation#[tap(builder)]- Auto-generates builder pattern
§Field-level Attributes
#[tap(participant)]- Single participant field (Party or Agent, required or optional)#[tap(participant_list)]- Vecfield for lists of agents #[tap(transaction_id)]- Transaction ID field (creates new transaction for initiators)#[tap(thread_id)]- Thread ID field (references existing transaction for replies)#[tap(connection_id)]- Connection ID field (for linking to Connect messages)