Skip to main content

ModelStorage

Trait ModelStorage 

Source
pub trait ModelStorage: Send + Sync {
    // Required methods
    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) -> PathBuf;
    fn storage_dir(&self) -> &Path;
}
Expand description

Model storage backend (sync version).

This trait defines operations for downloading and managing local models. Implementations include HuggingFaceStorage in spn-native.

For the async version, enable the async-storage feature.

Required Methods§

Source

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

List downloaded models.

§Errors

Returns error if the storage directory cannot be read.

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 model info for a specific model.

§Errors

Returns error if the model is not found.

Source

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

Delete a model.

§Errors

Returns error if the model cannot be deleted.

Source

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

Get the local path for a model.

Source

fn storage_dir(&self) -> &Path

Get the storage root directory.

Implementors§