pub struct SchemaRegistry { /* private fields */ }Expand description
Persistent store for trained ModelArtifacts.
Backed by a single portable .zsm binary file (b"ZSM\x01" magic +
bincode-serialized HashMap). The file is written atomically on every
mutation, a .zsm.tmp file is written first then renamed into place, so a
crash during flush can never leave a partially-written registry.
The registry is small in practice (< 1 000 entries), so nearest-neighbor lookup performs a full linear scan without an index.
Implementations§
Source§impl SchemaRegistry
impl SchemaRegistry
Sourcepub fn open(path: &Path) -> Result<SchemaRegistry, ZerError>
pub fn open(path: &Path) -> Result<SchemaRegistry, ZerError>
Open (or create) a registry at the given .zsm file path.
If the file does not exist yet it is created on the first Self::save call.
Sourcepub fn save(&self, artifact: &ModelArtifact) -> Result<(), ZerError>
pub fn save(&self, artifact: &ModelArtifact) -> Result<(), ZerError>
Persist a trained model artifact. Overwrites any existing artifact with the same schema hash and atomically flushes to disk.
Sourcepub fn get_exact(
&self,
fingerprint: &SchemaFingerprint,
) -> Result<Option<ModelArtifact>, ZerError>
pub fn get_exact( &self, fingerprint: &SchemaFingerprint, ) -> Result<Option<ModelArtifact>, ZerError>
Exact lookup by schema hash. Returns None if no matching artifact exists.
Sourcepub fn get_nearest(
&self,
fingerprint: &SchemaFingerprint,
) -> Result<Option<(ModelArtifact, f32)>, ZerError>
pub fn get_nearest( &self, fingerprint: &SchemaFingerprint, ) -> Result<Option<(ModelArtifact, f32)>, ZerError>
Nearest-neighbor lookup: returns the closest artifact and its distance.
Performs a full linear scan, acceptable because the registry is expected to hold far fewer than 1 000 entries.
Returns None when the registry is empty.
Sourcepub fn lookup_startup_mode(
&self,
fingerprint: &SchemaFingerprint,
) -> Result<StartupMode, ZerError>
pub fn lookup_startup_mode( &self, fingerprint: &SchemaFingerprint, ) -> Result<StartupMode, ZerError>
Determine the startup mode for an incoming dataset given its fingerprint.
exact hash match → WarmLoad (skip EM entirely)
distance ≤ 0.25 → WarmStart (2–3 EM iterations from saved init)
distance > 0.25 / empty → ColdStart (full EM from priors)Auto Trait Implementations§
impl !Freeze for SchemaRegistry
impl RefUnwindSafe for SchemaRegistry
impl Send for SchemaRegistry
impl Sync for SchemaRegistry
impl Unpin for SchemaRegistry
impl UnsafeUnpin for SchemaRegistry
impl UnwindSafe for SchemaRegistry
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
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