pub trait GraphExtractor: Send + Sync {
type NodeData: Clone + Send + Sync;
type EdgeData: Clone + Send + Sync;
// Required methods
fn extract_node(
&self,
base_path: &Path,
file_path: &Path,
frontmatter: &Value,
content: &str,
) -> Result<Self::NodeData>;
fn extract_edges(
&self,
frontmatter: &Value,
content: &str,
) -> Result<Option<Self::EdgeData>>;
fn to_graph_node(&self, node_data: &Self::NodeData) -> Node;
fn to_graph_edges(
&self,
from_id: &str,
edge_data: &Self::EdgeData,
) -> Vec<Edge>;
// Provided methods
fn content_glob(&self) -> &str { ... }
fn name(&self) -> &str { ... }
}Expand description
Trait for extracting graph data from domain-specific content.
Each knowledge domain (music theory, math, etc.) implements this trait to define how its markdown files with frontmatter are transformed into graph nodes and edges.
§Associated Types
NodeData: Domain-specific node information (e.g.,ConceptCard)EdgeData: Domain-specific relationship information (e.g.,RelatedConcepts)
§Lifecycle
For each content file, GraphBuilder calls:
extract_node()- Parse frontmatter + content intoNodeDataextract_edges()- Parse relationship data intoEdgeDatato_graph_node()- ConvertNodeDatato genericNodeto_graph_edges()- ConvertEdgeDatato genericVec<Edge>
Required Associated Types§
Required Methods§
Sourcefn extract_node(
&self,
base_path: &Path,
file_path: &Path,
frontmatter: &Value,
content: &str,
) -> Result<Self::NodeData>
fn extract_node( &self, base_path: &Path, file_path: &Path, frontmatter: &Value, content: &str, ) -> Result<Self::NodeData>
Extract node data from a content file.
§Arguments
base_path- Root directory for contentfile_path- Full path to the file being processedfrontmatter- Parsed YAML frontmatter as generic Valuecontent- Markdown body (after frontmatter)
Sourcefn extract_edges(
&self,
frontmatter: &Value,
content: &str,
) -> Result<Option<Self::EdgeData>>
fn extract_edges( &self, frontmatter: &Value, content: &str, ) -> Result<Option<Self::EdgeData>>
Extract relationship/edge data from content.
Returns Ok(None) if no relationships found (valid for leaf nodes).
Sourcefn to_graph_node(&self, node_data: &Self::NodeData) -> Node
fn to_graph_node(&self, node_data: &Self::NodeData) -> Node
Convert domain node data to a generic graph Node.
Provided Methods§
Sourcefn content_glob(&self) -> &str
fn content_glob(&self) -> &str
Returns the content glob pattern for this domain.
Used by GraphBuilder to discover content files.
Default: "**/*.md" (all markdown files recursively).