pub trait AsyncFunctionRegistry: Send + Sync {
type Function: Send + Sync;
type CallResult: Send + Sync;
type Error: Error + Send + Sync + 'static;
// Required methods
fn register<'life0, 'async_trait>(
&'life0 mut self,
name: String,
function: Self::Function,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Self::CallResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn list_functions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn has_function<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_function_info<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<FunctionInfo>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn call_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
calls: &'life1 [(&'life2 str, &'life3 str)],
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::CallResult>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn validate_args<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Async function calling abstraction for non-blocking tool usage
§Async Version
This trait provides async operations for function calling with better concurrency for tool usage.
Required Associated Types§
Sourcetype CallResult: Send + Sync
type CallResult: Send + Sync
The result type returned by function calls
Required Methods§
Sourcefn register<'life0, 'async_trait>(
&'life0 mut self,
name: String,
function: Self::Function,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn register<'life0, 'async_trait>(
&'life0 mut self,
name: String,
function: Self::Function,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Register a new function
Sourcefn call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Self::CallResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Self::CallResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Call a function by name with arguments
Sourcefn list_functions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_functions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List available functions
Sourcefn has_function<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_function<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a function exists
Sourcefn get_function_info<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<FunctionInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_function_info<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<FunctionInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get function metadata
Provided Methods§
Sourcefn call_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
calls: &'life1 [(&'life2 str, &'life3 str)],
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::CallResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn call_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
calls: &'life1 [(&'life2 str, &'life3 str)],
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::CallResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Call multiple functions concurrently
Sourcefn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Health check for function registry
Sourcefn validate_args<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn validate_args<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Validate function arguments before calling