use std::sync::Arc;
use anyhow::Result;
use crate::Disk;
use crate::DocumentLoader;
use crate::DocumentPath;
use crate::Documents;
use crate::TextLoader;
pub struct MarkdownLoader {
disk: Arc<dyn Disk>,
}
impl MarkdownLoader {
pub fn create(disk: Arc<dyn Disk>) -> Arc<Self> {
Arc::new(MarkdownLoader { disk })
}
}
#[async_trait::async_trait]
impl DocumentLoader for MarkdownLoader {
async fn load(&self, path: DocumentPath) -> Result<Documents> {
let text_loader = TextLoader::create(self.disk.clone());
text_loader.load(path).await
}
}