Enum NodeEvent

Source
pub enum NodeEvent {
    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>,
    },
}
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

Trait Implementations§

Source§

impl Clone for NodeEvent

Source§

fn clone(&self) -> NodeEvent

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 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> 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
Source§

impl<T> ErasedDestructor for T
where T: 'static,