pub struct ModelRegistry { /* private fields */ }Expand description
Model registry for managing model lifecycle
§Thread Safety
ModelRegistry uses Arc internally for efficient cloning and sharing across threads. The internal HashMap is immutable after creation, making concurrent reads safe without locks.
Implementations§
Source§impl ModelRegistry
impl ModelRegistry
Sourcepub fn get_model_metadata(
&self,
task: ModelTask,
variant: ModelVariant,
) -> Result<&ModelMetadata>
pub fn get_model_metadata( &self, task: ModelTask, variant: ModelVariant, ) -> Result<&ModelMetadata>
Sourcepub fn list_models(&self) -> Vec<&ModelMetadata>
pub fn list_models(&self) -> Vec<&ModelMetadata>
Sourcepub fn list_models_for_task(&self, task: ModelTask) -> Vec<&ModelMetadata>
pub fn list_models_for_task(&self, task: ModelTask) -> Vec<&ModelMetadata>
Sourcepub fn get_available_variants(&self, task: ModelTask) -> Vec<ModelVariant>
pub fn get_available_variants(&self, task: ModelTask) -> Vec<ModelVariant>
Sourcepub fn has_model(&self, task: ModelTask, variant: ModelVariant) -> bool
pub fn has_model(&self, task: ModelTask, variant: ModelVariant) -> bool
Check if a specific model is available in the registry
§Arguments
task- The model taskvariant- The model variant
§Returns
true if the model is registered, false otherwise
§Example
if registry.has_model(ModelTask::PromptInjection, ModelVariant::FP16) {
println!("Model is available!");
} else {
println!("Model not found");
}Sourcepub fn model_count(&self) -> usize
pub fn model_count(&self) -> usize
Sourcepub async fn ensure_model_available(
&self,
task: ModelTask,
variant: ModelVariant,
) -> Result<PathBuf>
pub async fn ensure_model_available( &self, task: ModelTask, variant: ModelVariant, ) -> Result<PathBuf>
Ensure a model is available locally (download if needed)
This method:
- Checks if model is already cached
- Verifies checksum if cached
- Downloads if not cached or verification fails
- Verifies checksum after download
§Arguments
task- The model taskvariant- The model variant
§Returns
Path to the local model file
Trait Implementations§
Source§impl Clone for ModelRegistry
impl Clone for ModelRegistry
Source§fn clone(&self) -> ModelRegistry
fn clone(&self) -> ModelRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ModelRegistry
impl Debug for ModelRegistry
Auto Trait Implementations§
impl Freeze for ModelRegistry
impl RefUnwindSafe for ModelRegistry
impl Send for ModelRegistry
impl Sync for ModelRegistry
impl Unpin for ModelRegistry
impl UnwindSafe for ModelRegistry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more