pub struct Catalog {
pub models: Vec<CatalogModel>,
pub dismissed_seeds: Vec<String>,
}Expand description
A collection of locally-available models.
Fields§
§models: Vec<CatalogModel>§dismissed_seeds: Vec<String>Seed ids the operator deleted; startup seeding never re-adds them.
Implementations§
Source§impl Catalog
impl Catalog
Sourcepub fn ensure_seeds(&mut self) -> bool
pub fn ensure_seeds(&mut self) -> bool
Add every seed this catalogue lacks (an install that predates it),
never replacing the operator’s entry and never re-adding a seed they
deleted. true when anything was added.
Sourcepub fn load_or_seed(path: &Path) -> Result<Self>
pub fn load_or_seed(path: &Path) -> Result<Self>
Load the catalog from path.
- Missing file → seeded with the built-in defaults and written.
- Corrupt JSON → the file is quarantined (renamed to
models.json.corrupt-<unix-ts>) and a fresh seed written in its place. The old behaviour — erroring so the caller fell back to an in-memory seed while keeping the save path — meant the next persist silently overwrote the operator’s hand-edited catalog; quarantining preserves their bytes for recovery. - Any other IO error propagates (nothing is renamed or written).
Sourcepub fn load_for_serving(path: Option<PathBuf>) -> (Self, Option<PathBuf>)
pub fn load_for_serving(path: Option<PathBuf>) -> (Self, Option<PathBuf>)
Load for serving: the catalog plus the path future saves may write to. A quarantine/seed recovery keeps the path (the file is now healthy); an unreadable file (permissions, IO) drops it so the worker can never overwrite a file it couldn’t read.
Sourcepub fn save(&self, path: &Path) -> Result<()>
pub fn save(&self, path: &Path) -> Result<()>
Write the catalog to path (creating parent dirs) — atomically,
via the same temp-file + rename dance as config.toml, so a
crash mid-write can’t truncate the operator’s model catalog.
Sourcepub fn get(&self, id: &str) -> Option<&CatalogModel>
pub fn get(&self, id: &str) -> Option<&CatalogModel>
Look up a model by id.
Sourcepub fn list(&self) -> &[CatalogModel]
pub fn list(&self) -> &[CatalogModel]
All catalog entries.
Sourcepub fn upsert(&mut self, model: CatalogModel)
pub fn upsert(&mut self, model: CatalogModel)
Insert a model, replacing any existing entry with the same id.
Sourcepub fn sync_studio_model(&mut self, incoming: CatalogModel) -> bool
pub fn sync_studio_model(&mut self, incoming: CatalogModel) -> bool
Mirror a model seen on a studio job offer into the catalog so
the local API can serve it too. Returns whether the catalog
changed (a no-op returns false, so the caller can skip the
disk write). A local-origin entry of the same id is never
clobbered — the operator’s own edits win; an unchanged
studio-origin entry is left alone so a re-offer every job
doesn’t churn the file.
Sourcepub fn default_image_model(&self) -> Option<&CatalogModel>
pub fn default_image_model(&self) -> Option<&CatalogModel>
The first enabled image model — used when a request names no model.
Sourcepub fn default_model_for(&self, kind: TaskKind) -> Option<&CatalogModel>
pub fn default_model_for(&self, kind: TaskKind) -> Option<&CatalogModel>
The first enabled model of kind — used when a request for that
kind names no explicit model. Generalises
default_image_model so the local
API can serve every modality the worker’s engines support.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Catalog
impl<'de> Deserialize<'de> for Catalog
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Catalog
Auto Trait Implementations§
impl Freeze for Catalog
impl RefUnwindSafe for Catalog
impl Send for Catalog
impl Sync for Catalog
impl Unpin for Catalog
impl UnsafeUnpin for Catalog
impl UnwindSafe for Catalog
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> ⓘ
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> ⓘ
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