pub trait Provider:
Send
+ Sync
+ Debug {
// Required methods
fn kind(&self) -> &'static str;
fn options(&self) -> ProviderOptions;
fn set_options(&mut self, options: ProviderOptions);
fn serialize_config(&self) -> Value;
fn complete<'life0, 'async_trait>(
&'life0 mut self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmTransportError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn clone_boxed(&self) -> Box<dyn Provider>;
// Provided methods
fn requires_streaming(&self) -> bool { ... }
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), LlmTransportError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
A configured LLM backend: its identity, host-config serialization, its generation options, and the request transport.
Required Methods§
fn kind(&self) -> &'static str
fn options(&self) -> ProviderOptions
fn set_options(&mut self, options: ProviderOptions)
Sourcefn serialize_config(&self) -> Value
fn serialize_config(&self) -> Value
Emit the provider-specific JSON body used by ProviderSpec. The
object must NOT contain a type field — [ProviderSpec::Serialize]
layers that on top.
fn complete<'life0, 'async_trait>(
&'life0 mut self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmTransportError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clone_boxed(&self) -> Box<dyn Provider>
Provided Methods§
fn requires_streaming(&self) -> bool
Sourcefn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), LlmTransportError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), LlmTransportError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Release any host-visible transport resources this provider holds — cached connections, pooled sockets, background tasks — sending whatever graceful close a clean shutdown requires.
Hosts call this before process exit so protocol niceties (e.g. WebSocket
Close frames) are sent rather than skipped by an abrupt drop. It takes
&self because a provider’s reusable transport state lives behind its
own synchronization; a shared clone can therefore be closed from the
shutdown path. The default is a no-op: providers that hold no reusable
transport state have nothing to release.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".