#![allow(dead_code)]
use std::borrow::Cow;
use std::ops::Range;
use std::string::String;
use std::vec::Vec;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum Severity {
Error,
Warning,
Help,
Info,
}
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub enum SourceId {
Schema,
Cli,
ConfigFile(String),
Other(String),
}
#[derive(Debug, Clone)]
pub struct SourceBundle {
pub id: SourceId,
pub name: Option<Cow<'static, str>>,
pub text: Cow<'static, str>,
}
#[derive(Debug, Clone)]
pub struct LabelSpec {
pub source: SourceId,
pub span: Range<usize>,
pub message: Cow<'static, str>,
pub is_primary: bool,
pub color: Option<ColorHint>,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum ColorHint {
Red,
Yellow,
Blue,
Cyan,
Green,
}
pub trait Diagnostic {
fn code(&self) -> &'static str;
fn label(&self) -> Cow<'static, str>;
fn help(&self) -> Option<Cow<'static, str>> {
None
}
fn notes(&self) -> Vec<Cow<'static, str>> {
Vec::new()
}
fn severity(&self) -> Severity {
Severity::Error
}
fn sources(&self) -> Vec<SourceBundle>;
fn labels(&self) -> Vec<LabelSpec>;
}