Skip to main content

NodeEvent

Enum NodeEvent 

Source
pub enum NodeEvent {
Show 15 variants PlainMessageReceived { message: Value, }, PlainMessageSent { message: Value, from: String, to: String, }, AgentRegistered { did: String, }, AgentUnregistered { did: String, }, DidResolved { did: String, success: bool, }, AgentPlainMessage { did: String, message: Vec<u8>, }, MessageRejected { message_id: String, reason: String, from: String, to: String, }, MessageAccepted { message_id: String, message_type: String, from: String, to: String, }, ReplyReceived { original_message_id: String, reply_message: PlainMessage, original_message: Box<PlainMessage>, }, TransactionStateChanged { transaction_id: String, old_state: String, new_state: String, agent_did: Option<String>, }, MessageReceived { message: PlainMessage, source: String, }, MessageSent { message: PlainMessage, destination: String, }, TransactionCreated { transaction: Transaction, agent_did: String, }, CustomerUpdated { customer_id: String, agent_did: String, update_type: String, }, DecisionRequired { transaction_id: String, transaction_state: String, decision: Value, pending_agents: Vec<String>, },
}
Expand description

Event types that can be emitted by the TAP Node

The NodeEvent enum represents all the possible events that can occur within a TAP Node. These events can be subscribed to using the EventBus to enable reactive programming patterns and loose coupling between components.

§Event Categories

Events are broadly categorized into:

  • PlainMessage Events: Related to message processing and delivery (PlainMessageReceived, PlainMessageSent)
  • Agent Events: Related to agent lifecycle management (AgentRegistered, AgentUnregistered)
  • Resolution Events: Related to DID resolution (DidResolved)
  • Raw PlainMessage Events: Raw binary messages for agents (AgentPlainMessage)

§Usage

Events are typically consumed by matching on the event type and taking appropriate action:

use tap_node::event::NodeEvent;

fn process_event(event: NodeEvent) {
    match event {
        NodeEvent::PlainMessageReceived { message } => {
            println!("PlainMessage received: {:?}", message);
        },
        NodeEvent::AgentRegistered { did } => {
            println!("Agent registered: {}", did);
        },
        // Handle other event types...
        _ => {}
    }
}

Variants§

§

PlainMessageReceived

A DIDComm message was received by the node

This event is triggered after a message has been successfully processed by the node’s incoming message processors. It contains the deserialized message content as a JSON Value.

§Parameters

  • message: The received message as a JSON Value

§Example Use Cases

  • Monitoring and logging received messages
  • Triggering follow-up actions based on message content
  • Auditing message flow through the system

Fields

§message: Value

The received message as a JSON Value

§

PlainMessageSent

A DIDComm message was sent from one agent to another

This event is triggered after a message has been successfully processed by the node’s outgoing message processors and prepared for delivery.

§Parameters

  • message: The sent message as a JSON Value
  • from: The DID of the sending agent
  • to: The DID of the receiving agent

§Example Use Cases

  • Tracking message delivery
  • Analyzing communication patterns
  • Generating message delivery receipts

Fields

§message: Value

The sent message as a JSON Value

§from: String

The DID of the sending agent

§to: String

The DID of the receiving agent

§

AgentRegistered

A new agent was registered with the node

This event is triggered when an agent is successfully registered with the node’s agent registry. It contains the DID of the registered agent.

§Parameters

  • did: The DID of the registered agent

§Example Use Cases

  • Tracking agent lifecycle
  • Initializing resources for new agents
  • Notifying other components of new agent availability

Fields

§did: String

The DID of the registered agent

§

AgentUnregistered

An agent was unregistered from the node

This event is triggered when an agent is removed from the node’s agent registry. It contains the DID of the unregistered agent.

§Parameters

  • did: The DID of the unregistered agent

§Example Use Cases

  • Cleanup of resources associated with the agent
  • Notifying other components of agent removal
  • Updating routing tables

Fields

§did: String

The DID of the unregistered agent

§

DidResolved

A DID was resolved by the node’s resolver

This event is triggered when the node attempts to resolve a DID. It includes both the DID being resolved and whether the resolution was successful.

§Parameters

  • did: The DID that was resolved
  • success: Whether the resolution was successful

§Example Use Cases

  • Monitoring resolution failures
  • Caching resolution results
  • Diagnostics and debugging

Fields

§did: String

The DID that was resolved

§success: bool

Whether the resolution was successful

§

AgentPlainMessage

A raw message event for an agent

This event contains raw binary message data intended for a specific agent. It is typically used for low-level message delivery mechanisms.

§Parameters

  • did: The DID of the target agent
  • message: The raw binary message data

§Example Use Cases

  • Direct message delivery to agents
  • Integration with transport-specific mechanisms
  • Binary protocol support

Fields

§did: String

The DID of the target agent

§message: Vec<u8>

The raw binary message data

§

MessageRejected

A message was rejected by validation

This event is triggered when a message fails validation checks and is rejected. It contains information about why the message was rejected.

§Parameters

  • message_id: The ID of the rejected message
  • reason: The reason for rejection
  • from: The DID of the sender
  • to: The DID of the intended recipient

§Example Use Cases

  • Monitoring validation failures
  • Alerting on suspicious activity
  • Debugging message flow issues

Fields

§message_id: String

The ID of the rejected message

§reason: String

The reason for rejection

§from: String

The DID of the sender

§to: String

The DID of the intended recipient

§

MessageAccepted

A message was accepted and processed

This event is triggered when a message passes all validation checks and is accepted for processing. It indicates successful message reception and validation.

§Parameters

  • message_id: The ID of the accepted message
  • message_type: The type of the message
  • from: The DID of the sender
  • to: The DID of the recipient

§Example Use Cases

  • Tracking successful message flow
  • Updating message status in database
  • Triggering downstream processing

Fields

§message_id: String

The ID of the accepted message

§message_type: String

The type of the message

§from: String

The DID of the sender

§to: String

The DID of the recipient

§

ReplyReceived

A reply was received for a previous message

This event is triggered when a message is received that is a reply to a previously sent message. It includes both the original message and the reply for context.

§Parameters

  • original_message_id: The ID of the original message
  • reply_message: The reply message
  • original_message: The original message being replied to

§Example Use Cases

  • Correlating request/response pairs
  • Tracking conversation flow
  • Implementing timeout handling

Fields

§original_message_id: String

The ID of the original message

§reply_message: PlainMessage

The reply message

§original_message: Box<PlainMessage>

The original message being replied to

§

TransactionStateChanged

A transaction’s state has changed

This event is triggered when a transaction transitions from one state to another. It includes information about the state transition and optionally the agent that triggered the change.

§Parameters

  • transaction_id: The ID of the transaction
  • old_state: The previous state
  • new_state: The new state
  • agent_did: The DID of the agent that triggered the change (if applicable)

§Example Use Cases

  • Monitoring transaction lifecycle
  • Triggering state-specific actions
  • Auditing state transitions

Fields

§transaction_id: String

The ID of the transaction

§old_state: String

The previous state

§new_state: String

The new state

§agent_did: Option<String>

The DID of the agent that triggered the change

§

MessageReceived

New events for customer extraction and compliance A message was received from a source

Fields

§message: PlainMessage

The received message

§source: String

The source of the message

§

MessageSent

A message was sent to a destination

Fields

§message: PlainMessage

The sent message

§destination: String

The destination of the message

§

TransactionCreated

A new transaction was created

Fields

§transaction: Transaction

The transaction data

§agent_did: String

The agent that created the transaction

§

CustomerUpdated

A customer record was created or updated

Fields

§customer_id: String

The customer ID

§agent_did: String

The agent that owns the customer

§update_type: String

The type of update (created, updated, verified)

§

DecisionRequired

A transaction reached a decision point that requires external input.

This event is published when the node’s DecisionMode is set to EventBus. External systems should subscribe to this event and call back into the node (via sending appropriate TAP messages) to advance the transaction.

§Parameters

  • transaction_id: The transaction requiring a decision
  • transaction_state: Current FSM state as a string
  • decision: The decision type as a serialized JSON value
  • pending_agents: DIDs of agents that still need to act

Fields

§transaction_id: String

The transaction requiring a decision

§transaction_state: String

Current FSM state

§decision: Value

The decision type and details (serialized Decision)

§pending_agents: Vec<String>

DIDs of agents that still need to act

Trait Implementations§

Source§

impl Clone for NodeEvent

Source§

fn clone(&self) -> NodeEvent

Returns a duplicate 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 Debug for NodeEvent

Source§

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

Formats the value using the given formatter. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more