pub trait ModelProvider:
Debug
+ Send
+ Sync {
// Required methods
fn provider_id(&self) -> &ProviderId;
fn models(&self) -> &[ModelSpec];
fn stream(
&self,
request: ModelRequest,
cancellation: ModelCancellation,
) -> BoxModelStream;
// Provided method
fn model(&self, model_id: &ModelId) -> Option<&ModelSpec> { ... }
}Expand description
Object-safe provider-neutral model adapter port.
Request setup, transport, protocol, cancellation, and runtime failures must be emitted through the returned stream as terminal failure events. Provider implementations must not panic for expected failures or create a nested asynchronous runtime.
Required Methods§
Sourcefn provider_id(&self) -> &ProviderId
fn provider_id(&self) -> &ProviderId
Returns the stable adapter/provider identity.
Sourcefn models(&self) -> &[ModelSpec]
fn models(&self) -> &[ModelSpec]
Returns models advertised by this adapter in deterministic order.
Sourcefn stream(
&self,
request: ModelRequest,
cancellation: ModelCancellation,
) -> BoxModelStream
fn stream( &self, request: ModelRequest, cancellation: ModelCancellation, ) -> BoxModelStream
Creates a lazy normalized stream for one immutable request.
cancellation is cooperative. Completion must not be reported until
resources owned directly by the stream have been cleaned up. Dropping
the stream abandons it; implementations must therefore keep resource
ownership inside the stream rather than a detached task.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".