Skip to main content

Module sender

Module sender 

Source
Expand description

PlainMessage sender implementations for TAP Node.

This module provides functionality for sending TAP messages to recipients using various transport mechanisms.

§Overview

The message sender system in TAP Node implements different strategies for delivering DIDComm messages to their recipients. The primary implementations are:

  • NodePlainMessageSender: A flexible sender that uses a callback function for delivery
  • HttpPlainMessageSender: Sends messages over HTTP with robust error handling and retries

§Cross-platform Support

The HttpPlainMessageSender implementation supports multiple platforms:

  • Native environments (using reqwest)
  • WASM environments (using web-sys)
  • Fallback implementations for environments without these libraries

§Usage with TapNode

// Create a TapNode
let node = TapNode::new(NodeConfig::default());

// Create a sample message
let message = PlainMessage {
    id: "test-123".to_string(),
    typ: "https://tap.rsvp/schema/1.0#transfer".to_string(),
    type_: "https://tap.rsvp/schema/1.0#transfer".to_string(),
    body: json!({"amount": "100.00"}),
    from: "did:example:sender".to_string(),
    to: vec!["did:example:recipient".to_string()],
    created_time: Some(chrono::Utc::now().timestamp() as u64),
    expires_time: None,
    thid: None,
    pthid: None,
    attachments: None,
    from_prior: None,
    extra_headers: Default::default(),
};

// Pack a message using the node's send_message method
let packed_message = node.send_message(
    "did:example:sender".to_string(),
    message
).await?;

// Create an HTTP sender for external dispatch
let sender = HttpPlainMessageSender::new("https://recipient-endpoint.example.com".to_string());

// Send the packed message to the recipient node
sender.send(
    packed_message,
    vec!["did:example:recipient".to_string()]
).await?;

Structs§

HttpPlainMessageSender
HTTP message sender implementation for sending messages over HTTP
HttpPlainMessageSenderWithTracking
HTTP message sender with delivery tracking
NodePlainMessageSender
Node message sender implementation
WebSocketPlainMessageSender
WebSocket message sender implementation for sending messages over WebSockets

Traits§

PlainMessageSender
PlainMessage sender trait for sending packed messages to recipients