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
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 Valuefrom: The DID of the sending agentto: The DID of the receiving agent
§Example Use Cases
- Tracking message delivery
- Analyzing communication patterns
- Generating message delivery receipts
Fields
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
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
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 resolvedsuccess: Whether the resolution was successful
§Example Use Cases
- Monitoring resolution failures
- Caching resolution results
- Diagnostics and debugging
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 agentmessage: The raw binary message data
§Example Use Cases
- Direct message delivery to agents
- Integration with transport-specific mechanisms
- Binary protocol support
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 messagereason: The reason for rejectionfrom: The DID of the senderto: The DID of the intended recipient
§Example Use Cases
- Monitoring validation failures
- Alerting on suspicious activity
- Debugging message flow issues
Fields
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 messagemessage_type: The type of the messagefrom: The DID of the senderto: The DID of the recipient
§Example Use Cases
- Tracking successful message flow
- Updating message status in database
- Triggering downstream processing
Fields
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 messagereply_message: The reply messageoriginal_message: The original message being replied to
§Example Use Cases
- Correlating request/response pairs
- Tracking conversation flow
- Implementing timeout handling
Fields
reply_message: PlainMessageThe 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 transactionold_state: The previous statenew_state: The new stateagent_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
MessageReceived
New events for customer extraction and compliance A message was received from a source
MessageSent
A message was sent to a destination
TransactionCreated
A new transaction was created
Fields
transaction: TransactionThe transaction data
CustomerUpdated
A customer record was created or updated
Fields
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 decisiontransaction_state: Current FSM state as a stringdecision: The decision type as a serialized JSON valuepending_agents: DIDs of agents that still need to act
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NodeEvent
impl RefUnwindSafe for NodeEvent
impl Send for NodeEvent
impl Sync for NodeEvent
impl Unpin for NodeEvent
impl UnsafeUnpin for NodeEvent
impl UnwindSafe for NodeEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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