pub trait ProviderIdentityExt: ProviderIdentity {
// Provided method
fn downcast_ref<T: Any + Send + Sync>(&self) -> Option<&T> { ... }
}Expand description
Typed access to ProviderIdentity::downcast_any.
Provided Methods§
Sourcefn downcast_ref<T: Any + Send + Sync>(&self) -> Option<&T>
fn downcast_ref<T: Any + Send + Sync>(&self) -> Option<&T>
Borrow the T this provider, or a provider it wraps, exposes.
Like anyhow::Error::downcast_ref, this looks through layers: it
reaches a concrete provider (and its provider-specific methods)
through wrappers and DynChatProvider:
use allama::mock::MockProvider;
use allama::wrappers::{RetryPolicy, RetryingProvider};
use allama::{DynChatProvider, ProviderIdentityExt};
let retrying = RetryingProvider::new(MockProvider::empty(), RetryPolicy::default());
let provider = DynChatProvider::new(retrying);
assert!(provider.downcast_ref::<MockProvider>().is_some());- Calls through the result skip the wrappers. The reference points at the inner provider, so its methods run without the retries, timeouts, tracing, or recording around it.
- The first match wins. A
FallbackProvideranswers from its primary first; when both sides have the same type, reach each one withprimaryandfallback. - Discovery is for code handed an already-wrapped provider. An
application that builds the stack can keep a clone (or an
Arc) of the concrete provider before wrapping it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".