pub struct FunctionToolHandler { /* private fields */ }
Expand description
Function-based tool handler
Implementations§
Source§impl FunctionToolHandler
impl FunctionToolHandler
Sourcepub fn new<F, Fut>(tool: Tool, handler: F) -> Selfwhere
F: Fn(CallToolRequest, RequestContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ServerResult<CallToolResult>> + Send + 'static,
pub fn new<F, Fut>(tool: Tool, handler: F) -> Selfwhere
F: Fn(CallToolRequest, RequestContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ServerResult<CallToolResult>> + Send + 'static,
Create a new function-based tool handler
Sourcepub fn new_with_roles<F, Fut>(
tool: Tool,
handler: F,
allowed_roles: Option<Vec<String>>,
) -> Selfwhere
F: Fn(CallToolRequest, RequestContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ServerResult<CallToolResult>> + Send + 'static,
pub fn new_with_roles<F, Fut>(
tool: Tool,
handler: F,
allowed_roles: Option<Vec<String>>,
) -> Selfwhere
F: Fn(CallToolRequest, RequestContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ServerResult<CallToolResult>> + Send + 'static,
Create a new function-based tool handler with RBAC roles
Trait Implementations§
Source§impl Debug for FunctionToolHandler
impl Debug for FunctionToolHandler
Source§impl ToolHandler for FunctionToolHandler
impl ToolHandler for FunctionToolHandler
Source§fn handle<'life0, 'async_trait>(
&'life0 self,
request: CallToolRequest,
ctx: RequestContext,
) -> Pin<Box<dyn Future<Output = ServerResult<CallToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
request: CallToolRequest,
ctx: RequestContext,
) -> Pin<Box<dyn Future<Output = ServerResult<CallToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a tool call request
Source§fn tool_definition(&self) -> Tool
fn tool_definition(&self) -> Tool
Get the tool definition
Source§fn allowed_roles(&self) -> Option<&[String]>
fn allowed_roles(&self) -> Option<&[String]>
Allowed roles for this tool (RBAC). None means unrestricted.
Source§fn validate_input(&self, _input: &Value) -> ServerResult<()>
fn validate_input(&self, _input: &Value) -> ServerResult<()>
Validate tool input (optional, default implementation allows all)
Auto Trait Implementations§
impl Freeze for FunctionToolHandler
impl !RefUnwindSafe for FunctionToolHandler
impl Send for FunctionToolHandler
impl Sync for FunctionToolHandler
impl Unpin for FunctionToolHandler
impl !UnwindSafe for FunctionToolHandler
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
Mutably borrows from an owned value. Read more