Skip to main content

GraphBuilder

Struct GraphBuilder 

Source
pub struct GraphBuilder<E: GraphExtractor> { /* private fields */ }
Expand description

Builder for constructing knowledge graphs.

Generic over E: GraphExtractor to support any domain.

§Caching

When a cache path is configured via with_cache_path, the builder checks if the cached graph is fresh before rebuilding. On cache hit, the graph is loaded from disk in milliseconds instead of re-parsing all content files.

Implementations§

Source§

impl<E: GraphExtractor> GraphBuilder<E>

Source

pub fn new(extractor: E) -> Self

Creates a new builder with the given extractor.

Source

pub fn with_content_path(self, path: impl Into<PathBuf>) -> Self

Sets the content directory path.

Source

pub fn with_manual_edges(self, path: impl Into<PathBuf>) -> Self

Adds manual edges from a JSON file (Amendment §2f-iii).

Source

pub fn with_error_handling(self, handling: ErrorHandling) -> Self

Sets the error handling strategy.

Source

pub fn with_cache_path(self, path: impl Into<PathBuf>) -> Self

Sets the cache file path for graph persistence.

When set, the builder will:

  1. Check if the cache is fresh before building (by comparing content hashes)
  2. Load from cache on hit (fast path)
  3. Save to cache after a successful build (for next time)
Source

pub fn skip_cache(self) -> Self

Forces a rebuild even if the cache is fresh.

Source

pub async fn build(self) -> Result<(GraphData, BuildStats)>

Builds the graph.

Uses a two-phase approach (adapted from Taproot):

  • Phase 1: Extract and add all nodes
  • Phase 2: Extract and add all edges (with dedup and dangling ref tracking)

If a cache path is configured and the cache is fresh, loads from cache instead.

Auto Trait Implementations§

§

impl<E> Freeze for GraphBuilder<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for GraphBuilder<E>
where E: RefUnwindSafe,

§

impl<E> Send for GraphBuilder<E>

§

impl<E> Sync for GraphBuilder<E>

§

impl<E> Unpin for GraphBuilder<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for GraphBuilder<E>
where E: UnsafeUnpin,

§

impl<E> UnwindSafe for GraphBuilder<E>
where E: 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> 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.