Struct TapNode

Source
pub struct TapNode { /* private fields */ }
Expand description

§The TAP Node

The TAP Node is the core component responsible for coordinating message processing, routing, and delivery to TAP Agents. It serves as a central hub for all TAP communications and transaction coordination.

§Core Responsibilities

  • Agent Management: Registration and deregistration of TAP Agents
  • Message Processing: Processing incoming and outgoing messages through middleware chains
  • Message Routing: Determining the appropriate recipient for each message
  • Event Publishing: Broadcasting node events to subscribers
  • Scalability: Managing concurrent message processing through worker pools

§Lifecycle

  1. Create a node with appropriate configuration
  2. Register one or more agents with the node
  3. Start the processor pool (if high throughput is required)
  4. Process incoming/outgoing messages
  5. Publish and respond to events

§Thread Safety

The TapNode is designed to be thread-safe and can be shared across multiple threads using an Arc<TapNode>. All internal mutability is handled through appropriate synchronization primitives.

Implementations§

Source§

impl TapNode

Source

pub fn new(config: NodeConfig) -> Self

Create a new TAP node with the given configuration

Source

pub async fn start(&mut self, config: ProcessorPoolConfig) -> Result<()>

Start the node

Source

pub async fn receive_message(&self, message: Message) -> Result<()>

Receive and process an incoming message

This method handles the complete lifecycle of an incoming message:

  1. Processing the message through all registered processors
  2. Routing the message to determine the appropriate target agent
  3. Dispatching the message to the target agent

The processing pipeline may transform or even drop the message based on validation rules or other processing logic. If a message is dropped during processing, this method will return Ok(()) without an error.

§Parameters
  • message - The DIDComm message to be processed
§Returns
  • Ok(()) if the message was successfully processed and dispatched (or intentionally dropped)
  • Err(Error) if there was an error during processing, routing, or dispatching
§Errors

This method can return errors for several reasons:

  • Processing errors from message processors
  • Routing errors if no target agent can be determined
  • Dispatch errors if the target agent cannot be found or fails to process the message
§Example
// Process an incoming message
node.receive_message(message).await?;
Source

pub async fn dispatch_message( &self, target_did: String, message: Message, ) -> Result<()>

Dispatch a message to an agent by DID

Source

pub async fn send_message( &self, from_did: &str, to_did: &str, message: Message, ) -> Result<String>

Send a message from one agent to another

This method handles the processing, routing, and delivery of a message from one agent to another. It returns the packed message.

Source

pub async fn register_agent(&self, agent: Arc<DefaultAgent>) -> Result<()>

Register a new agent with the node

Source

pub async fn unregister_agent(&self, did: &str) -> Result<()>

Unregister an agent from the node

Source

pub fn get_all_agent_dids(&self) -> Vec<String>

Get all registered agent DIDs

Source

pub fn get_event_bus(&self) -> Arc<EventBus>

Get the event bus

Source

pub fn get_resolver(&self) -> Arc<NodeResolver>

Get the resolver

Source

pub fn config(&self) -> &NodeConfig

Get the node config

Source

pub fn agents(&self) -> &AgentRegistry

Get the agent registry

Trait Implementations§

Source§

impl Clone for TapNode

Source§

fn clone(&self) -> TapNode

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

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Return a reference to self as Any
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,