Skip to main content

Unverified

Struct Unverified 

Source
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>

Source

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 { .. }),
));
Source

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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Unverified<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq> Eq for Unverified<T>

Source§

impl<T: PartialEq> PartialEq for Unverified<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.