LanguageParser

Trait LanguageParser 

Source
pub trait LanguageParser {
    // Required method
    fn parse_file(&mut self, file_path: &Path) -> Result<FileUnit>;
}
Expand description

Trait for language-specific parsers.

This trait is implemented by parsers for different programming languages to provide consistent parsing behavior.

§Examples

use codebank::{LanguageParser, FileUnit, Result};
use std::path::{Path, PathBuf};

struct MyParser;

impl LanguageParser for MyParser {
    fn parse_file(&mut self, file_path: &Path) -> Result<FileUnit> {
        // Simple implementation that creates an empty FileUnit
        Ok(FileUnit::new(file_path.to_path_buf()))
    }
}

let mut parser = MyParser;
let file_unit = parser.parse_file(Path::new("example.rs"))?;
assert_eq!(file_unit.path, PathBuf::from("example.rs"));

Required Methods§

Source

fn parse_file(&mut self, file_path: &Path) -> Result<FileUnit>

Parse a file into a FileUnit

Implementors§