pub struct ProviderRegistry { /* private fields */ }Expand description
Registry of all available stream providers, keyed by API protocol.
Implementations§
Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub fn register(
&mut self,
protocol: ApiProtocol,
provider: impl StreamProvider + 'static,
)
pub fn register( &mut self, protocol: ApiProtocol, provider: impl StreamProvider + 'static, )
Register a provider for a given protocol.
Sourcepub fn resolve(&self, protocol: &ApiProtocol) -> Option<Arc<dyn StreamProvider>>
pub fn resolve(&self, protocol: &ApiProtocol) -> Option<Arc<dyn StreamProvider>>
Resolve the provider for a protocol as a shared handle.
Unlike get, this hands out an owned Arc that can be
stored (e.g. by Agent::from_config),
so callers don’t have to borrow the registry for the provider’s
lifetime.
Sourcepub fn get(&self, protocol: &ApiProtocol) -> Option<&dyn StreamProvider>
pub fn get(&self, protocol: &ApiProtocol) -> Option<&dyn StreamProvider>
Borrow the provider for a protocol for a transient call. Prefer
resolve when you need to keep the handle.
Sourcepub fn has(&self, protocol: &ApiProtocol) -> bool
pub fn has(&self, protocol: &ApiProtocol) -> bool
Check if a protocol is registered.
Sourcepub fn protocols(&self) -> Vec<ApiProtocol>
pub fn protocols(&self) -> Vec<ApiProtocol>
List all registered protocols.
Sourcepub async fn stream(
&self,
model: &ModelConfig,
config: StreamConfig,
tx: UnboundedSender<StreamEvent>,
cancel: CancellationToken,
) -> Result<Message, ProviderError>
pub async fn stream( &self, model: &ModelConfig, config: StreamConfig, tx: UnboundedSender<StreamEvent>, cancel: CancellationToken, ) -> Result<Message, ProviderError>
Stream using the appropriate provider for the model’s API protocol.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ProviderRegistry
impl !UnwindSafe for ProviderRegistry
impl Freeze for ProviderRegistry
impl Send for ProviderRegistry
impl Sync for ProviderRegistry
impl Unpin for ProviderRegistry
impl UnsafeUnpin for ProviderRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more