Skip to main content

grapha_core/
extract.rs

1use std::path::Path;
2
3use crate::graph::{Edge, Node};
4use crate::resolve::Import;
5
6#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
7pub struct ExtractionResult {
8    pub nodes: Vec<Node>,
9    pub edges: Vec<Edge>,
10    pub imports: Vec<Import>,
11}
12
13impl Default for ExtractionResult {
14    fn default() -> Self {
15        Self::new()
16    }
17}
18
19impl ExtractionResult {
20    pub fn new() -> Self {
21        Self {
22            nodes: Vec::new(),
23            edges: Vec::new(),
24            imports: Vec::new(),
25        }
26    }
27}
28
29pub trait LanguageExtractor {
30    fn extract(&self, source: &[u8], file_path: &Path) -> anyhow::Result<ExtractionResult>;
31}