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>
impl<E: GraphExtractor> GraphBuilder<E>
Sourcepub fn with_content_path(self, path: impl Into<PathBuf>) -> Self
pub fn with_content_path(self, path: impl Into<PathBuf>) -> Self
Sets the content directory path.
Sourcepub fn with_manual_edges(self, path: impl Into<PathBuf>) -> Self
pub fn with_manual_edges(self, path: impl Into<PathBuf>) -> Self
Adds manual edges from a JSON file (Amendment §2f-iii).
Sourcepub fn with_error_handling(self, handling: ErrorHandling) -> Self
pub fn with_error_handling(self, handling: ErrorHandling) -> Self
Sets the error handling strategy.
Sourcepub fn with_cache_path(self, path: impl Into<PathBuf>) -> Self
pub fn with_cache_path(self, path: impl Into<PathBuf>) -> Self
Sets the cache file path for graph persistence.
When set, the builder will:
- Check if the cache is fresh before building (by comparing content hashes)
- Load from cache on hit (fast path)
- Save to cache after a successful build (for next time)
Sourcepub fn skip_cache(self) -> Self
pub fn skip_cache(self) -> Self
Forces a rebuild even if the cache is fresh.
Sourcepub async fn build(self) -> Result<(GraphData, BuildStats)>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more