pub trait LanguageModel:
Sealed
+ Send
+ Sync {
// Provided methods
fn is_available(&self) -> bool { ... }
fn availability(&self) -> ModelAvailability { ... }
fn ensure_available(&self) -> Result<()> { ... }
fn context_size(&self) -> Result<u64> { ... }
}Expand description
A Foundation Models implementation that can create a crate::Session.
This sealed abstraction supports both the on-device model and model types introduced by newer Apple SDKs without allowing invalid external FFI implementations.
Provided Methods§
Sourcefn is_available(&self) -> bool
fn is_available(&self) -> bool
Checks whether the model is currently available.
Sourcefn availability(&self) -> ModelAvailability
fn availability(&self) -> ModelAvailability
Returns the current reason-specific model availability.
Sourcefn ensure_available(&self) -> Result<()>
fn ensure_available(&self) -> Result<()>
Returns a reason-specific error if the model is unavailable.
Sourcefn context_size(&self) -> Result<u64>
fn context_size(&self) -> Result<u64>
Returns the model context window size in tokens.
For the on-device model this is reported synchronously (26.4+ build
SDK required); for Private Cloud Compute it performs a network
request and can fail with Error::NetworkFailure or
Error::ServiceUnavailable.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl LanguageModel for PrivateCloudComputeLanguageModel
Available on crate feature
private-cloud-compute only.