Struct Transfer

Source
pub struct Transfer {
    pub asset: AssetId,
    pub originator: Participant,
    pub beneficiary: Option<Participant>,
    pub amount: String,
    pub agents: Vec<Participant>,
    pub memo: Option<String>,
    pub settlement_id: Option<String>,
    pub transaction_id: String,
    pub metadata: HashMap<String, Value>,
}
Expand description

Transfer message body (TAIP-3).

Fields§

§asset: AssetId

Network asset identifier (CAIP-19 format).

§originator: Participant

Originator information.

§beneficiary: Option<Participant>

Beneficiary information (optional).

§amount: String

Transfer amount.

§agents: Vec<Participant>

Agents involved in the transfer.

§memo: Option<String>

Memo for the transfer (optional).

§settlement_id: Option<String>

Settlement identifier (optional).

§transaction_id: String

Transaction identifier (not stored in the struct but accessible via the TapMessage trait).

§metadata: HashMap<String, Value>

Additional metadata for the transfer.

Implementations§

Source§

impl Transfer

Source

pub fn builder() -> TransferBuilder

Create a new Transfer

§Example
use tap_msg::message::Transfer;
use tap_caip::{AssetId, ChainId};
use tap_msg::message::Participant;
use std::collections::HashMap;

// Create chain ID and asset ID
let chain_id = ChainId::new("eip155", "1").unwrap();
let asset = AssetId::new(chain_id, "erc20", "0x6b175474e89094c44da98b954eedeac495271d0f").unwrap();

// Create participant
let originator = Participant {
    id: "did:example:alice".to_string(),
    role: Some("originator".to_string()),
    policies: None,
    leiCode: None,
};

// Create a transfer with required fields
let transfer = Transfer::builder()
    .asset(asset)
    .originator(originator)
    .amount("100".to_string())
    .build();
Source

pub fn message_id(&self) -> String

Generates a unique message ID for authorization, rejection, or settlement

Source

pub fn validate(&self) -> Result<()>

Validate the Transfer

Trait Implementations§

Source§

impl Authorizable for Transfer

Implementation of Authorizable for Transfer

Source§

fn authorize(&self, note: Option<String>) -> Authorize

Authorizes this message, creating an Authorize message as a response

§Arguments
  • note - Optional note
§Returns

A new Authorize message body

Source§

fn confirm_relationship( &self, transaction_id: String, agent_id: String, for_id: String, role: Option<String>, ) -> ConfirmRelationship

Confirms a relationship between agents, creating a ConfirmRelationship message as a response

§Arguments
  • transfer_id - ID of the transfer related to this message
  • agent_id - DID of the agent whose relationship is being confirmed
  • for_id - DID of the entity that the agent acts on behalf of
  • role - Optional role of the agent in the transaction
§Returns

A new ConfirmRelationship message body

Source§

fn reject(&self, code: String, description: String) -> Reject

Rejects this message, creating a Reject message as a response

§Arguments
  • code - Rejection code
  • description - Description of rejection reason
§Returns

A new Reject message body

Source§

fn settle(&self, settlement_id: String, amount: Option<String>) -> Settle

Settles this message, creating a Settle message as a response

§Arguments
  • settlement_id - Settlement ID (CAIP-220 identifier)
  • amount - Optional amount settled
§Returns

A new Settle message body

Source§

fn update_party( &self, transaction_id: String, party_type: String, party: Participant, note: Option<String>, ) -> UpdateParty

Updates a party in the transaction, creating an UpdateParty message as a response

§Arguments
  • transfer_id - ID of the transaction this update relates to
  • party_type - Type of party being updated (e.g., ‘originator’, ‘beneficiary’)
  • party - Updated party information
  • note - Optional note about the update
§Returns

A new UpdateParty message body

Source§

fn update_policies( &self, transaction_id: String, policies: Vec<Policy>, ) -> UpdatePolicies

Updates policies for this message, creating an UpdatePolicies message as a response

§Arguments
  • transaction_id - ID of the transaction being updated
  • policies - Vector of policies to be applied
§Returns

A new UpdatePolicies message body

Source§

fn add_agents( &self, transaction_id: String, agents: Vec<Participant>, ) -> AddAgents

Adds agents to this message, creating an AddAgents message as a response

§Arguments
  • transaction_id - ID of the transaction to add agents to
  • agents - Vector of participants to be added
§Returns

A new AddAgents message body

Source§

fn replace_agent( &self, transaction_id: String, original: String, replacement: Participant, ) -> ReplaceAgent

Replaces an agent in this message, creating a ReplaceAgent message as a response

§Arguments
  • transaction_id - ID of the transaction to replace agent in
  • original - DID of the original agent to be replaced
  • replacement - New participant replacing the original agent
§Returns

A new ReplaceAgent message body

Source§

fn remove_agent(&self, transaction_id: String, agent: String) -> RemoveAgent

Removes an agent from this message, creating a RemoveAgent message as a response

§Arguments
  • transaction_id - ID of the transaction to remove agent from
  • agent - DID of the agent to remove
§Returns

A new RemoveAgent message body

Source§

impl Clone for Transfer

Source§

fn clone(&self) -> Transfer

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Connectable for Transfer

Source§

fn with_connection(&mut self, connect_id: &str) -> &mut Self

Connect this message to a prior Connect message by setting the parent thread ID (pthid). Read more
Source§

fn has_connection(&self) -> bool

Check if this message is connected to a prior Connect message. Read more
Source§

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

Get the connection ID if present. Read more
Source§

impl Debug for Transfer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Transfer

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Transfer

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TapMessage for Transfer

Source§

fn validate(&self) -> Result<()>

Validates a TAP message. Read more
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. Read more
Source§

fn get_all_participants(&self) -> Vec<String>

Get all participant DIDs from this message. Read more
Source§

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

Create a reply to this message. Read more
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
Source§

impl TapMessageBody for Transfer

Source§

fn message_type() -> &'static str

Get the message type string for this body type.
Source§

fn validate(&self) -> Result<()>

Validate the message body.
Source§

fn to_didcomm(&self, from_did: Option<&str>) -> Result<Message>

Convert this body to a DIDComm message.
Source§

fn to_didcomm_with_route<'a, I>( &self, from: Option<&str>, to: I, ) -> Result<Message>
where I: IntoIterator<Item = &'a str>,

Convert this body to a DIDComm message with a sender and multiple recipients. Read more
Source§

fn from_didcomm(message: &Message) -> Result<Self>
where Self: Sized,

Extract this body type from a DIDComm message.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,