Skip to main content

ModelStorage

Trait ModelStorage 

Source
pub trait ModelStorage {
    // Required methods
    async fn download<F>(
        &self,
        request: &DownloadRequest<'_>,
        progress: F,
    ) -> Result<DownloadResult>
       where F: Fn(PullProgress) + Send + 'static;
    fn list_models(&self) -> Result<Vec<ModelInfo>, BackendError>;
    fn exists(&self, model_id: &str) -> bool;
    fn model_info(&self, model_id: &str) -> Result<ModelInfo, BackendError>;
    fn delete(&self, model_id: &str) -> Result<(), BackendError>;
    fn model_path(&self, model_id: &str) -> Result<PathBuf, BackendError>;
}
Expand description

Trait for model storage backends.

Provides a common interface for downloading and managing local models.

Required Methods§

Source

async fn download<F>( &self, request: &DownloadRequest<'_>, progress: F, ) -> Result<DownloadResult>
where F: Fn(PullProgress) + Send + 'static,

Download a model with progress callback.

Source

fn list_models(&self) -> Result<Vec<ModelInfo>, BackendError>

List all downloaded models.

Source

fn exists(&self, model_id: &str) -> bool

Check if a model exists locally.

Source

fn model_info(&self, model_id: &str) -> Result<ModelInfo, BackendError>

Get info about a local model.

Source

fn delete(&self, model_id: &str) -> Result<(), BackendError>

Delete a local model.

Source

fn model_path(&self, model_id: &str) -> Result<PathBuf, BackendError>

Get the path to a model file.

§Security

Validates that model_id doesn’t escape storage directory via path traversal.

§Errors

Returns BackendError::PathTraversal if the path would escape the storage directory.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§