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 new() -> Self
pub fn new() -> Self
Create an empty registry (no providers registered).
Use ProviderRegistry::default() to get all built-in providers.
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 get(&self, protocol: &ApiProtocol) -> Option<&dyn StreamProvider>
pub fn get(&self, protocol: &ApiProtocol) -> Option<&dyn StreamProvider>
Get a reference to the provider for a given protocol, if registered.
Sourcepub fn has(&self, protocol: &ApiProtocol) -> bool
pub fn has(&self, protocol: &ApiProtocol) -> bool
Returns true if a provider is registered for the given protocol.
Sourcepub fn protocols(&self) -> Vec<ApiProtocol>
pub fn protocols(&self) -> Vec<ApiProtocol>
List all protocols that have a registered provider.
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 Freeze for ProviderRegistry
impl !RefUnwindSafe for ProviderRegistry
impl Send for ProviderRegistry
impl Sync for ProviderRegistry
impl Unpin for ProviderRegistry
impl UnsafeUnpin for ProviderRegistry
impl !UnwindSafe 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