1#![deny(
2 warnings,
3 clippy::all,
4 clippy::pedantic,
5 unreachable_pub,
6 unused_allocation,
7 unused_extern_crates,
8 unused_assignments,
9 unused_comparisons
10)]
11#![allow(
12clippy::match_bool, clippy::missing_errors_doc, clippy::module_name_repetitions, clippy::semicolon_if_nothing_returned, clippy::needless_pass_by_value, )]
18
19pub use diagnostic::{Diagnostic, DiagnosticList};
20pub use formatter::Formatter;
21pub use label::Label;
22pub use note::Note;
23pub use severity::Severity;
24pub use span::{Span, span};
25
26#[allow(clippy::module_inception)]
27mod diagnostic;
28mod formatter;
29mod label;
30mod note;
31mod severity;
32mod span;
33
34const VRL_DOCS_ROOT_URL: &str = "https://vrl.dev";
35const VRL_ERROR_DOCS_ROOT_URL: &str = "https://errors.vrl.dev";
36const VRL_FUNCS_ROOT_URL: &str = "https://functions.vrl.dev";
37
38pub trait DiagnosticMessage: std::error::Error {
41 fn code(&self) -> usize;
42
43 fn message(&self) -> String {
47 self.to_string()
48 }
49
50 fn labels(&self) -> Vec<Label> {
54 vec![]
55 }
56
57 fn notes(&self) -> Vec<Note> {
61 vec![]
62 }
63
64 fn severity(&self) -> Severity {
68 Severity::Error
69 }
70}
71
72pub struct Urls;
73
74impl Urls {
75 fn vrl_root_url() -> String {
76 VRL_DOCS_ROOT_URL.into()
77 }
78
79 #[must_use]
80 pub fn func_docs(ident: &str) -> String {
81 format!("{VRL_FUNCS_ROOT_URL}/{ident}")
82 }
83
84 fn error_handling_url() -> String {
85 format!("{VRL_ERROR_DOCS_ROOT_URL}/#handling")
86 }
87
88 fn error_code_url(code: usize) -> String {
89 format!("{VRL_ERROR_DOCS_ROOT_URL}/{code}")
90 }
91
92 #[must_use]
93 pub fn expression_docs_url(expr: &str) -> String {
94 format!("{VRL_DOCS_ROOT_URL}/expressions/{expr}")
95 }
96
97 fn example_docs() -> String {
98 format!("{VRL_DOCS_ROOT_URL}/examples")
99 }
100
101 #[must_use]
102 pub fn func_characteristics() -> String {
103 format!("{VRL_DOCS_ROOT_URL}/expressions/#function-call-characteristics")
104 }
105}