pub trait ModelLister<H = Client>: WasmCompatSend + WasmCompatSync {
type Client;
// Required methods
fn new(client: Self::Client) -> Self;
fn list_all(
&self,
) -> impl Future<Output = Result<ModelList, ModelListingError>> + WasmCompatSend;
}Expand description
A trait for implementing model listing logic for a specific provider.
This trait should be implemented by provider-specific types that handle the
details of making HTTP requests to list models and converting provider-specific
responses into the generic Model format. Providers with pagination
support should internally fetch all pages before returning results.
§Type Parameters
H: The HTTP client type (typicallyreqwest::Client)
§Example Implementation
ⓘ
use crate::client::ModelLister;
use crate::model::{Model, ModelList, ModelListingError};
struct MyProviderModelLister<H> {
client: Client<MyProviderExt, H>,
}
impl<H> ModelLister<H> for MyProviderModelLister<H>
where
H: HttpClientExt + Send + Sync,
{
type Client = Client<MyProviderExt, H>;
fn new(client: Self::Client) -> Self {
Self { client }
}
async fn list_all(&self) -> Result<ModelList, ModelListingError> {
// Fetch all models (handle pagination internally if needed)
todo!()
}
}Required Associated Types§
Required Methods§
Sourcefn list_all(
&self,
) -> impl Future<Output = Result<ModelList, ModelListingError>> + WasmCompatSend
fn list_all( &self, ) -> impl Future<Output = Result<ModelList, ModelListingError>> + WasmCompatSend
List all available models from the provider.
This implementation should handle fetching all pages if the provider supports pagination, returning complete results in a single call.
§Returns
A ModelList containing all available models.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.