Skip to main content

BinaryTrieRouter

Struct BinaryTrieRouter 

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

Compile-time generated tool router with O(1) dispatch

Implementations§

Source§

impl BinaryTrieRouter

Source

pub const MAX_TOOLS: usize = CapabilityManifest::MAX_TOOLS

Maximum number of tools supported

Source

pub fn new() -> Self

Create a new empty router

Source

pub fn with_capacity(capacity: usize) -> Self

Create a router with pre-allocated capacity

Source

pub fn register( &mut self, handler: Box<dyn ToolHandler>, ) -> Result<u16, DCPError>

Register a tool handler

Source

pub fn tool_schema(&self, tool_id: u16) -> Option<&ToolSchema>

Get the registered schema for a tool ID.

Source

pub fn execute( &self, tool_id: u16, args: &SharedArgs<'_>, ) -> Result<ToolResult, DCPError>

Raw tool execution is deny-by-default.

Runtime callers must use execute_authorized with a negotiated capability manifest so tool execution cannot bypass authorization.

Source

pub fn execute_authorized( &self, capabilities: &CapabilityManifest, tool_id: u16, args: &SharedArgs<'_>, ) -> Result<ToolResult, SecurityError>

Execute a tool only if it is present in the negotiated capability set.

Source

pub fn execute_signed_authorized( &self, capabilities: &CapabilityManifest, invocation: &SignedInvocation, public_key: &[u8; 32], nonce_store: &mut NonceStore, args: &SharedArgs<'_>, ) -> Result<ToolResult, SecurityError>

Execute a signed invocation only after signature, args hash, negotiated capability, schema, and replay checks all pass.

Source

pub fn resolve_name(&self, name: &str) -> Option<u16>

Resolve tool name to ID (for MCP compatibility)

Source

pub fn max_tool_id(&self) -> u16

Get the maximum registered tool ID

Source

pub fn tool_count(&self) -> usize

Get the number of registered tools

Source

pub fn has_tool(&self, tool_id: u16) -> bool

Check if a tool ID is registered

Source

pub fn tool_names(&self) -> impl Iterator<Item = &str>

Get all registered tool names

Source

pub fn capabilities(&self) -> ServerCapabilities

Get server capabilities based on registered tools

Trait Implementations§

Source§

impl Default for BinaryTrieRouter

Source§

fn default() -> Self

Returns the “default value” for a type. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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