use serde::{Deserialize, Serialize};
use crate::format::FormatId;
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub enum DiagnosticSeverity {
Info,
Warning,
Error,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct TranslationDiagnostic {
pub severity: DiagnosticSeverity,
pub code: String,
pub message: String,
pub source: Option<FormatId>,
pub target: Option<FormatId>,
pub path: Option<String>,
}
impl TranslationDiagnostic {
pub fn warning(code: impl Into<String>, message: impl Into<String>) -> Self {
Self {
severity: DiagnosticSeverity::Warning,
code: code.into(),
message: message.into(),
source: None,
target: None,
path: None,
}
}
pub fn at_path(mut self, path: impl Into<String>) -> Self {
self.path = Some(path.into());
self
}
pub fn with_formats(
mut self,
source: impl Into<FormatId>,
target: impl Into<FormatId>,
) -> Self {
self.source = Some(source.into());
self.target = Some(target.into());
self
}
}