#![deny(
warnings,
clippy::all,
clippy::pedantic,
unreachable_pub,
unused_allocation,
unused_extern_crates,
unused_assignments,
unused_comparisons
)]
#![allow(
clippy::match_bool, clippy::missing_errors_doc, clippy::module_name_repetitions, clippy::semicolon_if_nothing_returned, clippy::needless_pass_by_value, )]
pub use diagnostic::{Diagnostic, DiagnosticList};
pub use formatter::Formatter;
pub use label::Label;
pub use note::Note;
pub use severity::Severity;
pub use span::{span, Span};
#[allow(clippy::module_inception)]
mod diagnostic;
mod formatter;
mod label;
mod note;
mod severity;
mod span;
const VRL_DOCS_ROOT_URL: &str = "https://vrl.dev";
const VRL_ERROR_DOCS_ROOT_URL: &str = "https://errors.vrl.dev";
const VRL_FUNCS_ROOT_URL: &str = "https://functions.vrl.dev";
pub trait DiagnosticMessage: std::error::Error {
fn code(&self) -> usize;
fn message(&self) -> String {
self.to_string()
}
fn labels(&self) -> Vec<Label> {
vec![]
}
fn notes(&self) -> Vec<Note> {
vec![]
}
fn severity(&self) -> Severity {
Severity::Error
}
}
pub struct Urls;
impl Urls {
fn vrl_root_url() -> String {
VRL_DOCS_ROOT_URL.into()
}
#[must_use]
pub fn func_docs(ident: &str) -> String {
format!("{VRL_FUNCS_ROOT_URL}/{ident}")
}
fn error_handling_url() -> String {
format!("{VRL_ERROR_DOCS_ROOT_URL}/#handling")
}
fn error_code_url(code: usize) -> String {
format!("{VRL_ERROR_DOCS_ROOT_URL}/{code}")
}
#[must_use]
pub fn expression_docs_url(expr: &str) -> String {
format!("{VRL_DOCS_ROOT_URL}/expressions/{expr}")
}
fn example_docs() -> String {
format!("{VRL_DOCS_ROOT_URL}/examples")
}
#[must_use]
pub fn func_characteristics() -> String {
format!("{VRL_DOCS_ROOT_URL}/expressions/#function-call-characteristics")
}
}