pub struct Element { /* private fields */ }Expand description
A representation of a JSON element that satisfies the needs of most consumers of a Warning.
This representation avoids the complexity of needing to provide a 'buf lifetime to the json::Element.
This would complicate all warnings types with that lifetime.
A consumer of warnings wants to group them by [json::ElemId] using Warning::group_by_elem and then
display or report the warnings by path.
The linter report also wants to highlight the source JSON that a warning refers too.
Implementations§
Source§impl Element
impl Element
pub fn span(&self) -> Span
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Examples found in repository?
More examples
examples/price_cdr_with_unknown_version.rs (line 92)
89fn print_timezone_error(error: &warning::Error<timezone::Warning>) {
90 eprintln!(
91 "ERR: Unable to find timezone due to error at path `{}`: {}",
92 error.element().path(),
93 error.warning()
94 );
95}
96
97fn print_timezone_warnings(warnings: &warning::Set<timezone::Warning>) {
98 if warnings.is_empty() {
99 return;
100 }
101
102 eprintln!(
103 "WARN: {} warnings from the timezone search",
104 warnings.len_warnings()
105 );
106
107 eprintln!(
108 "WARN: {} warnings from the timezone search:\n {}",
109 warnings.len_warnings(),
110 warning::SetWriter::new(warnings)
111 );
112}
113
114fn print_pricing_error(error: &warning::Error<price::Warning>) {
115 eprintln!(
116 "ERR: Unable to price CDR due to error at path `{}`: {}",
117 error.element().path(),
118 error.warning()
119 );
120}pub fn into_parts(self) -> (Span, Path)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnsafeUnpin for Element
impl UnwindSafe for Element
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more