Skip to main content

Pack

Struct Pack 

Source
pub struct Pack { /* private fields */ }
Expand description

A parsed, digest-verified pack.

Constructed by Pack::load, Pack::from_bytes, or once for the whole process by embedded. Every span was bounds- and boundary-checked at construction, so the accessors on Provider and Operation cannot fail.

Implementations§

Source§

impl Pack

Source

pub fn load(path: impl AsRef<Path>) -> Result<Pack, Error>

Read and verify a pack at path — the constructor for a host loading a newer catalogue than it was built with. Refuses a wrong format version, schema version or digest before serving any record.

§Errors

Error::Io when the file cannot be read; otherwise everything from_bytes refuses.

Source

pub fn from_bytes(bytes: Vec<u8>) -> Result<Pack, Error>

Verify and parse a pack from bytes already in hand.

§Errors

Every Error variant except Error::Io; see each variant for what it refuses.

Source

pub fn schema_version(&self) -> u32

The document schema version the pack carries.

Source

pub fn digest(&self) -> &str

The verified content digest, as lowercase hex — the pack’s identity, usable as a cache key.

Source

pub fn providers(&self) -> impl ExactSizeIterator<Item = Provider<'_>>

Every provider in the pack, in id order.

Source

pub fn provider(&self, id: &str) -> Option<Provider<'_>>

One provider by id.

Source

pub fn operations(&self) -> impl ExactSizeIterator<Item = Operation<'_>>

Every operation in the pack, in id order.

Source

pub fn operation(&self, id: &str) -> Option<Operation<'_>>

One operation by id.

Source

pub fn operations_of<'s>( &'s self, provider: &str, ) -> impl Iterator<Item = Operation<'s>> + 's

Every operation of one provider, in id order. An unknown provider yields nothing, exactly as the legacy catalogue’s operations_of does.

Trait Implementations§

Source§

impl Debug for Pack

Source§

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

The identity and the shape, never the 9-MB payload: a {:?} in a log must not print the catalogue at an operator.

Auto Trait Implementations§

§

impl Freeze for Pack

§

impl RefUnwindSafe for Pack

§

impl Send for Pack

§

impl Sync for Pack

§

impl Unpin for Pack

§

impl UnsafeUnpin for Pack

§

impl UnwindSafe for Pack

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.