pub struct Unverified<T>(/* private fields */);Expand description
An object whose identity has not been checked.
Deliberately opaque: the inner object is reachable only by verifying it,
or by Unverified::peek for diagnostics that must not feed the graph.
Implementations§
Source§impl Unverified<Object>
impl Unverified<Object>
Sourcepub fn verify(self, expected: &Cid) -> Result<Verified<Object>, ObjectError>
pub fn verify(self, expected: &Cid) -> Result<Verified<Object>, ObjectError>
Confirm the bytes hash to expected.
§Errors
Returns ObjectError::IdentifierMismatch if they do not.
§Example
use publet_core::{Cid, HashAlg, Object, ObjectError};
let bytes = Object::builder("claim.prose", AUTHOR).created("2026-10-05T00:00:00Z").build()?;
assert!(Object::parse(&bytes)?.verify(&Cid::of(&bytes, HashAlg::Sha2_256)).is_ok());
// Bytes that are not the ones the identifier names are refused.
let asked_for = Cid::of(b"something else", HashAlg::Sha2_256);
assert!(matches!(
Object::parse(&bytes)?.verify(&asked_for),
Err(ObjectError::IdentifierMismatch { .. }),
));Sourcepub fn peek(&self) -> &Object
pub fn peek(&self) -> &Object
Borrow the object without verifying it.
For error messages and inspection tools only. Nothing that indexes, evaluates, or stores should take this path.
§Example
use publet_core::Object;
let bytes = Object::builder("claim.prose", AUTHOR).created("2026-10-05T00:00:00Z").build()?;
// For a diagnostic message only; nothing should act on an unverified object.
let unverified = Object::parse(&bytes)?;
assert_eq!(unverified.peek().kind(), "claim.prose");Trait Implementations§
Source§impl<T: Clone> Clone for Unverified<T>
impl<T: Clone> Clone for Unverified<T>
Source§impl<T: Debug> Debug for Unverified<T>
impl<T: Debug> Debug for Unverified<T>
impl<T: Eq> Eq for Unverified<T>
Source§impl<T: PartialEq> PartialEq for Unverified<T>
impl<T: PartialEq> PartialEq for Unverified<T>
impl<T: PartialEq> StructuralPartialEq for Unverified<T>
Auto Trait Implementations§
impl<T> Freeze for Unverified<T>where
T: Freeze,
impl<T> RefUnwindSafe for Unverified<T>where
T: RefUnwindSafe,
impl<T> Send for Unverified<T>where
T: Send,
impl<T> Sync for Unverified<T>where
T: Sync,
impl<T> Unpin for Unverified<T>where
T: Unpin,
impl<T> UnsafeUnpin for Unverified<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Unverified<T>where
T: UnwindSafe,
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