pub struct ModelStore { /* private fields */ }Implementations§
Source§impl ModelStore
impl ModelStore
pub fn new(dir: impl Into<PathBuf>) -> Self
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
$WEIRDNET_MODELS_DIR, else <user data dir>/weirdnet/models; the Hub from
$WEIRDNET_HF_URL (a mirror) when set; this node’s Hugging Face token
(HfToken::from_env), which is sent only to the public Hub, never to a mirror.
Sourcepub fn with_token(self, token: Option<HfToken>) -> Self
pub fn with_token(self, token: Option<HfToken>) -> Self
Sends token to this store’s Hub, whichever it is (a mirror too).
Sourcepub fn hub_client(&self) -> Hub
pub fn hub_client(&self) -> Hub
A Hub client for this store’s Hub, with the token when it may go there.
Sourcepub fn with_hub(self, hub: impl Into<String>) -> Self
pub fn with_hub(self, hub: impl Into<String>) -> Self
Use another Hub (a mirror, or a local server in tests).
pub fn dir(&self) -> &Path
pub fn hub(&self) -> &str
Sourcepub fn installed(&self, spec: &ModelSpec) -> bool
pub fn installed(&self, spec: &ModelSpec) -> bool
Downloaded and complete: the size matches (the checksum was checked when it finished).
Sourcepub fn partial_bytes(&self, spec: &ModelSpec) -> u64
pub fn partial_bytes(&self, spec: &ModelSpec) -> u64
Bytes of a partial download, if any.
Sourcepub fn remove(&self, spec: &ModelSpec) -> bool
pub fn remove(&self, spec: &ModelSpec) -> bool
Deletes the file and any partial download. Returns whether a file was removed.
Sourcepub fn list(&self) -> Vec<StoredModel>
pub fn list(&self) -> Vec<StoredModel>
The GGUF models in the store (split parts grouped; projector, draft and .part files
left out), sorted by id.
Sourcepub fn remove_local(&self, model: &StoredModel) -> Result<u64>
pub fn remove_local(&self, model: &StoredModel) -> Result<u64>
Deletes a listed model’s files (and their .part files) and the directories that leaves
empty. Returns the bytes freed. Paths outside the store are refused.