Skip to main content

Bundle

Struct Bundle 

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

A loaded OKF bundle.

Implementations§

Source§

impl Bundle

Source

pub fn load(root: impl AsRef<Path>) -> Result<Self, BundleError>

Loads a bundle from a directory tree.

Returns an error only for I/O failures or a non-directory root. Per-file parse failures are recorded in Bundle::parse_errors.

§Errors

Returns BundleError::NotADirectory if root does not exist or is not a directory, and BundleError::Io for any underlying I/O failure while walking the tree.

Source

pub fn root(&self) -> &Path

The bundle’s root directory.

Source

pub fn concepts(&self) -> &[Concept]

All successfully parsed concepts, in path order.

Source

pub const fn len(&self) -> usize

Number of concepts.

Source

pub const fn is_empty(&self) -> bool

true if the bundle has no concepts.

Source

pub fn get(&self, id: &ConceptId) -> Option<&Concept>

Looks up a concept by id.

Source

pub fn contains(&self, id: &ConceptId) -> bool

true if a concept with this id exists.

Source

pub fn index_files(&self) -> &[PathBuf]

Paths of all index.md files found (§6).

Source

pub fn log_files(&self) -> &[PathBuf]

Paths of all log.md files found (§7).

Source

pub fn parse_errors(&self) -> &[(PathBuf, DocumentError)]

Files whose frontmatter could not be parsed during loading.

The resolved outbound cross-links from a concept.

The ids of concepts that link to the given concept (“cited by” / § backlinks).

All broken internal links in the bundle, as (source, raw_target) pairs. Broken links are permitted by the spec (§6.1), so this is informational.

Source

pub fn okf_version(&self) -> Option<&str>

The declared OKF version from the bundle-root index.md frontmatter, if present (okf_version, §12). This is the only place frontmatter is permitted in an index.md.

Cached at load time, so this is cheap to call repeatedly. A consumer that does not understand the declared version SHOULD attempt best-effort consumption rather than refusing the bundle, so this is reported, never enforced.

Returns None whether the root index.md is absent, unreadable, or lacks the key; a malformed root index.md is reported separately by validate_bundle.

Source

pub fn sources_of(&self, id: &ConceptId) -> &[ResolvedSource]

The concept’s sources entries, each resolved against the bundle.

Source

pub fn derived_from(&self, id: &ConceptId) -> Vec<&ConceptId>

The concepts this one derives from: the sources[].resource entries that name another concept in this bundle (§5.1).

Following these recursively is how a consumer lets credibility propagate; external leaf sources carry only their intrinsic signals.

Source

pub fn derives(&self, id: &ConceptId) -> &[ConceptId]

The reverse of Bundle::derived_from: concepts that cite this one as a source.

Source

pub fn concepts_of_type<'a>( &'a self, type_: &'a str, ) -> impl Iterator<Item = &'a Concept>

Every concept whose type matches exactly.

Source

pub fn attested_computations(&self) -> impl Iterator<Item = &Concept>

Every Attested Computation concept in the bundle (§10.1).

This is the discovery path §10.5 describes: a consumer reaches a computation by type, or by following a link from a concept that uses it.

Source

pub fn tags(&self) -> BTreeMap<String, Vec<ConceptId>>

A tag index synthesized by scanning frontmatter, tag to concept ids.

§3.1: OKF does not specify a file format for aggregating documents by tag, so “a consumer that wants a tag-browsing view can synthesize one at consumption time.” This is that view.

Source

pub fn stale_on(&self, today: Date) -> Vec<&Concept>

Every concept that is stale on today: today >= stale_after (§5.5).

Source

pub fn resolve_path_field(&self, from: &ConceptId, raw: &str) -> Option<PathBuf>

Resolves a path-valued frontmatter field to a file inside the bundle.

Returns the first candidate from links::field_path_candidates that actually exists on disk, or None for a URL, a scope descriptor, or a path that names nothing. Unlike concept links, these fields routinely point at non-markdown files such as references/attesters/revenue.py.

Trait Implementations§

Source§

impl Debug for Bundle

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.