pub struct ObjectIntegrityChecker { /* private fields */ }Expand description
Production-grade multi-level object integrity checker.
Thread-safety is the caller’s responsibility; wrap in Arc<Mutex<…>> if
shared across threads.
Implementations§
Source§impl ObjectIntegrityChecker
impl ObjectIntegrityChecker
Sourcepub fn new(config: CheckerConfig) -> Self
pub fn new(config: CheckerConfig) -> Self
Create a new checker with the provided configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a new checker with default configuration.
Sourcepub fn register(
&mut self,
id: String,
data: &[u8],
) -> Result<IntegrityHash, CheckerError>
pub fn register( &mut self, id: String, data: &[u8], ) -> Result<IntegrityHash, CheckerError>
Register a new object and compute its canonical hashes.
Returns the IntegrityHash on success. Returns
CheckerError::MaxObjectsExceeded if the configured cap is reached.
Re-registering an existing id overwrites the stored record.
Sourcepub fn verify(
&mut self,
id: &str,
data: &[u8],
level: IntegrityLevel,
) -> Result<OicVerificationResult, CheckerError>
pub fn verify( &mut self, id: &str, data: &[u8], level: IntegrityLevel, ) -> Result<OicVerificationResult, CheckerError>
Verify data against the stored hashes for id at the given level.
Updates the object’s status, last_verified_at, and
verification_count. Returns a detailed OicVerificationResult.
Sourcepub fn verify_all(
&mut self,
objects: &[(&str, &[u8])],
level: IntegrityLevel,
) -> Vec<OicVerificationResult>
pub fn verify_all( &mut self, objects: &[(&str, &[u8])], level: IntegrityLevel, ) -> Vec<OicVerificationResult>
Batch-verify multiple (id, data) pairs at the given level.
Objects that are not found are reported as failed verifications with an error message rather than causing a panic or early abort.
Sourcepub fn mark_corrupted(
&mut self,
id: &str,
reason: String,
) -> Result<(), CheckerError>
pub fn mark_corrupted( &mut self, id: &str, reason: String, ) -> Result<(), CheckerError>
Mark an object as PossiblyCorrupted with a caller-supplied reason.
Sourcepub fn update(
&mut self,
id: &str,
new_data: &[u8],
) -> Result<IntegrityHash, CheckerError>
pub fn update( &mut self, id: &str, new_data: &[u8], ) -> Result<IntegrityHash, CheckerError>
Replace the stored canonical hashes with freshly computed values from
new_data and reset the verification counter.
Sourcepub fn remove(&mut self, id: &str) -> Result<(), CheckerError>
pub fn remove(&mut self, id: &str) -> Result<(), CheckerError>
Deregister an object, freeing its stored record.
Sourcepub fn corrupted_objects(&self) -> Vec<&OicObjectRecord>
pub fn corrupted_objects(&self) -> Vec<&OicObjectRecord>
Return references to all objects currently in a Corrupted state.
Sourcepub fn objects_needing_verification(
&self,
since_us: u64,
) -> Vec<&OicObjectRecord>
pub fn objects_needing_verification( &self, since_us: u64, ) -> Vec<&OicObjectRecord>
Return references to objects whose last_verified_at is older than
since_us (i.e. last_verified_at < since_us), including those that
have never been verified (last_verified_at == 0).
Sourcepub fn repair_hash(
&mut self,
id: &str,
correct_data: &[u8],
) -> Result<(), CheckerError>
pub fn repair_hash( &mut self, id: &str, correct_data: &[u8], ) -> Result<(), CheckerError>
Recompute hashes from correct_data and clear any corruption status.
This is the “repair” path: after retrieving a known-good copy of an object, call this to reset the canonical digest and mark the object as verified.
Sourcepub fn stats(&self) -> CheckerStats
pub fn stats(&self) -> CheckerStats
Snapshot current aggregate statistics.
Sourcepub fn config(&self) -> &CheckerConfig
pub fn config(&self) -> &CheckerConfig
Access the underlying configuration.
Auto Trait Implementations§
impl Freeze for ObjectIntegrityChecker
impl RefUnwindSafe for ObjectIntegrityChecker
impl Send for ObjectIntegrityChecker
impl Sync for ObjectIntegrityChecker
impl Unpin for ObjectIntegrityChecker
impl UnsafeUnpin for ObjectIntegrityChecker
impl UnwindSafe for ObjectIntegrityChecker
Blanket Implementations§
impl<T> Allocation for T
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> 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