use std::sync::Arc;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum DiagnosticSeverity {
Info,
Warning,
Error,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum DiagnosticKind {
Scientific,
Execution,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Diagnostic {
pub code: Arc<str>,
pub kind: DiagnosticKind,
pub severity: DiagnosticSeverity,
pub message: Arc<str>,
pub artifact_id: Option<Arc<str>>,
pub fields: Arc<[(Arc<str>, Arc<str>)]>,
}
impl Diagnostic {
#[must_use]
pub fn new(
code: impl Into<Arc<str>>,
kind: DiagnosticKind,
severity: DiagnosticSeverity,
message: impl Into<Arc<str>>,
) -> Self {
Self {
code: code.into(),
kind,
severity,
message: message.into(),
artifact_id: None,
fields: Arc::from([]),
}
}
}
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct DiagnosticSet {
pub entries: Vec<Diagnostic>,
}
impl DiagnosticSet {
#[must_use]
pub fn new() -> Self {
Self::default()
}
pub fn push(&mut self, diagnostic: Diagnostic) {
self.entries.push(diagnostic);
}
#[must_use]
pub fn len(&self) -> usize {
self.entries.len()
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.entries.is_empty()
}
}