pub trait AiProvider: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn is_available<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn request<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 AiRequest,
events: Option<UnboundedSender<AiEvent>>,
) -> Pin<Box<dyn Future<Output = Result<AiResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Trait for AI backends that can process requests.
Implementors provide access to an AI model, either through a local CLI tool (Tier 1) or a direct HTTP API client (Tier 2, future).
Required Methods§
Sourcefn is_available<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_available<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check whether this provider is available (e.g., CLI tool is installed).
Sourcefn request<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 AiRequest,
events: Option<UnboundedSender<AiEvent>>,
) -> Pin<Box<dyn Future<Output = Result<AiResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn request<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 AiRequest,
events: Option<UnboundedSender<AiEvent>>,
) -> Pin<Box<dyn Future<Output = Result<AiResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a request to the AI provider.
If events is provided, real-time events (like tool calls) are sent
through the channel during processing.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".