pub struct Bundle { /* private fields */ }Expand description
A loaded OKF bundle.
Implementations§
Source§impl Bundle
impl Bundle
Sourcepub fn load(root: impl AsRef<Path>) -> Result<Self, BundleError>
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.
Sourcepub fn index_files(&self) -> &[PathBuf]
pub fn index_files(&self) -> &[PathBuf]
Paths of all index.md files found (§6).
Sourcepub fn parse_errors(&self) -> &[(PathBuf, DocumentError)]
pub fn parse_errors(&self) -> &[(PathBuf, DocumentError)]
Files whose frontmatter could not be parsed during loading.
Sourcepub fn links_from(&self, id: &ConceptId) -> &[ResolvedLink]
pub fn links_from(&self, id: &ConceptId) -> &[ResolvedLink]
The resolved outbound cross-links from a concept.
Sourcepub fn backlinks(&self, id: &ConceptId) -> &[ConceptId]
pub fn backlinks(&self, id: &ConceptId) -> &[ConceptId]
The ids of concepts that link to the given concept (“cited by” / § backlinks).
Sourcepub fn broken_links(&self) -> Vec<(ConceptId, String)>
pub fn broken_links(&self) -> Vec<(ConceptId, String)>
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.
Sourcepub fn okf_version(&self) -> Option<&str>
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.
Sourcepub fn sources_of(&self, id: &ConceptId) -> &[ResolvedSource]
pub fn sources_of(&self, id: &ConceptId) -> &[ResolvedSource]
The concept’s sources entries, each resolved against the bundle.
Sourcepub fn derived_from(&self, id: &ConceptId) -> Vec<&ConceptId>
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.
Sourcepub fn derives(&self, id: &ConceptId) -> &[ConceptId]
pub fn derives(&self, id: &ConceptId) -> &[ConceptId]
The reverse of Bundle::derived_from: concepts that cite this one as
a source.
Sourcepub fn concepts_of_type<'a>(
&'a self,
type_: &'a str,
) -> impl Iterator<Item = &'a Concept>
pub fn concepts_of_type<'a>( &'a self, type_: &'a str, ) -> impl Iterator<Item = &'a Concept>
Every concept whose type matches exactly.
Sourcepub fn attested_computations(&self) -> impl Iterator<Item = &Concept>
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.
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.
Sourcepub fn stale_on(&self, today: Date) -> Vec<&Concept>
pub fn stale_on(&self, today: Date) -> Vec<&Concept>
Every concept that is stale on today: today >= stale_after (§5.5).
Sourcepub fn resolve_path_field(&self, from: &ConceptId, raw: &str) -> Option<PathBuf>
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.