pub trait LayeredProvider: Sized + Provider {
type Inner: Provider;
// Required method
fn inner(&self) -> &Self::Inner;
// Provided methods
fn layered_info(&self) -> Arc<ProviderInfo> { ... }
fn layered_chat_completion<'life0, 'async_trait>(
&'life0 self,
req: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletionResponse, AiError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn layered_stream_chat_completion<'life0, 'async_trait>(
&'life0 self,
req: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Box<ChatCompletionStream>, AiError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Helper trait for layered providers.
This trait provides default forwarding implementations for provider methods, similar to OpenDAL’s LayeredProvider. Implementers only need to override the methods they want to intercept.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn layered_info(&self) -> Arc<ProviderInfo>
fn layered_info(&self) -> Arc<ProviderInfo>
Default implementation for info - forwards to inner
Sourcefn layered_chat_completion<'life0, 'async_trait>(
&'life0 self,
req: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletionResponse, AiError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn layered_chat_completion<'life0, 'async_trait>(
&'life0 self,
req: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletionResponse, AiError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Default implementation for chat_completion - forwards to inner
Sourcefn layered_stream_chat_completion<'life0, 'async_trait>(
&'life0 self,
req: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Box<ChatCompletionStream>, AiError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn layered_stream_chat_completion<'life0, 'async_trait>(
&'life0 self,
req: ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<Box<ChatCompletionStream>, AiError>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Default implementation for stream_chat_completion - forwards to inner
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.