use dictx_core::{DictEntry, Result};
use std::path::Path;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ValidationReport {
pub valid: bool,
pub format: String,
pub estimated_entries: Option<usize>,
pub issues: Vec<String>,
}
impl ValidationReport {
pub fn ok(format: impl Into<String>, estimated_entries: Option<usize>) -> Self {
Self {
valid: true,
format: format.into(),
estimated_entries,
issues: Vec::new(),
}
}
pub fn invalid(format: impl Into<String>, issue: impl Into<String>) -> Self {
Self {
valid: false,
format: format.into(),
estimated_entries: None,
issues: vec![issue.into()],
}
}
}
pub trait DictParser: Send + Sync {
fn name(&self) -> &'static str;
fn format_id(&self) -> &'static str;
fn validate(&self, path: &Path) -> Result<ValidationReport>;
fn parse(&self, path: &Path) -> Result<Box<dyn Iterator<Item = Result<DictEntry>>>>;
}