Skip to main content

DepGraph

Struct DepGraph 

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

Directed link/embed edges between pages, keyed by source path.

Built once per build via DepGraph::build; queried via DepGraph::backlinks and DepGraph::back_embeds. Embed edges are a subset already present in forward_links/backlinksforward_embeds/back_embeds narrow to just LinkType::Embed because embeds are more render-relevant than plain links (a transcluded page’s body IS part of the embedding page’s output).

Implementations§

Source§

impl DepGraph

Source

pub fn build<'a, I>(pages: I) -> Self
where I: IntoIterator<Item = (&'a str, &'a [OutgoingLink])>,

Build a DepGraph from each page’s source path and the outgoing links it resolved during parsing. Order of pages does not affect the result — edge lists within a bucket follow input order for determinism, but no page’s presence depends on any other’s.

Source

pub fn with_embed_pairs<'a, I>(self, pairs: I) -> Self
where I: IntoIterator<Item = (&'a str, &'a str)>,

Fold in transclusion edges recorded by the resolve phase (moss#922 Stage 7).

pairs are (target, immediate_embedder) — exactly the shape ResolveResult::embed_deps produces (resolve/embeds.rs), i.e. DIRECT one-hop edges: for index.md embedding a.md embedding b.md the resolver reports [("a.md", "index.md"), ("b.md", "a.md")]. The second element is the file the marker was found in, NOT the top-level page being resolved, so grouping by it yields a correct adjacency list and multi-hop chains are answered by Self::embed_closure, never by filtering pairs on the page under test (which would silently miss b.md as a dependency of index.md).

This exists as a separate builder step, ContentGraph::with_output_overrides style, because these edges are produced by a different phase than outgoing_links: transclusion is spliced from disk bytes during resolve, before the AST dispatcher that populates outgoing_links ever runs, so no page→page LinkType::Embed link exists to carry them.

Duplicate edges (the same nested pair is reported once per ancestor that transitively embeds it) are collapsed.

Source

pub fn embed_closure(&self, path: &str) -> Vec<String>

Every file whose bytes are spliced into path’s markdown, transitively.

A breadth-first walk of forward_embeds from path, excluding path itself, bounded by MAX_EMBED_DEPTH — the same limit resolve_embeds_inner stops recursing at, so the closure never claims a dependency on content the resolver refused to splice. Cycles terminate on the visited set.

This is the parse cache’s validity input (moss#922 Stage 7): path’s cached ParsedDocument is only reusable if every member of this set still hashes to what it hashed to when the entry was written.

Pages path links to (any LinkType), in resolution order. Empty if path has no outgoing links or is not a source in this graph.

Source

pub fn forward_embeds(&self, path: &str) -> &[String]

Pages path embeds (LinkType::Embed only). Subset of forward_links.

Pages that link to path (any LinkType). Empty if nothing links here.

Source

pub fn back_embeds(&self, path: &str) -> &[String]

Pages that embed path (LinkType::Embed only). Subset of backlinks.

Trait Implementations§

Source§

impl Clone for DepGraph

Source§

fn clone(&self) -> DepGraph

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 Debug for DepGraph

Source§

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

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

impl Default for DepGraph

Source§

fn default() -> DepGraph

Returns the “default value” for a type. 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> 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> 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 = 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.