use std::path::PathBuf; use std::path::Path; use anyhow::Result; use crate::Server; pub trait FileTypeParser { fn parse(&self, server: &Server, path: &Path, ext: &str, doc: tantivy::Document) -> Result; } pub struct TextFileParser; impl FileTypeParser for TextFileParser { fn parse(&self, server: &Server, path: &Path, ext: &str, mut doc: tantivy::Document) -> Result { let body = std::fs::read_to_string(path)?; doc.add_text(server.field_body(), body); Ok(doc) } } pub struct MarkdownParser; impl FileTypeParser for MarkdownParser { fn parse(&self, server: &Server, path: &Path, ext: &str, doc: tantivy::Document) -> Result { unimplemented!() } }