pub struct InvariantRegistry { /* private fields */ }Expand description
Registry mapping each PageType to its PageInvariant implementation.
Built once and shared via Arc so tests can swap in a mock registry.
§Examples
use zeph_context::typed_page::{InvariantRegistry, PageType};
let reg = InvariantRegistry::default();
let inv = reg.get(PageType::ToolOutput).unwrap();
assert_eq!(inv.page_type(), PageType::ToolOutput);Implementations§
Source§impl InvariantRegistry
impl InvariantRegistry
Sourcepub fn get(&self, page_type: PageType) -> Option<&dyn PageInvariant>
pub fn get(&self, page_type: PageType) -> Option<&dyn PageInvariant>
Look up the invariant for a given PageType.
Always returns Some for the four built-in variants.
Sourcepub fn enforce(
&self,
original: &TypedPage,
compacted: &CompactedPage,
) -> Result<(), Vec<FidelityViolation>>
pub fn enforce( &self, original: &TypedPage, compacted: &CompactedPage, ) -> Result<(), Vec<FidelityViolation>>
Verify that compacted satisfies the invariant for original at a compaction boundary.
This is the primary entry point for the compactor — it wraps verify() in a
tracing::info_span! per NFR-009 so every compaction boundary is observable.
Returns Ok(()) when the invariant is satisfied, or the violation list on failure.
§Errors
Propagates FidelityViolations from the registered invariant implementation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InvariantRegistry
impl !RefUnwindSafe for InvariantRegistry
impl Send for InvariantRegistry
impl Sync for InvariantRegistry
impl Unpin for InvariantRegistry
impl UnsafeUnpin for InvariantRegistry
impl !UnwindSafe for InvariantRegistry
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request