pub struct Versioned<'buf> { /* private fields */ }Expand description
A json::Element that has been parsed by the either the parse_with_version or parse functions
and was determined to be one of the supported Versions.
Implementations§
Source§impl<'buf> Versioned<'buf>
impl<'buf> Versioned<'buf>
Sourcepub fn into_element(self) -> Element<'buf>
pub fn into_element(self) -> Element<'buf>
Return the inner json::Element and discard the version info.
Sourcepub fn as_element(&self) -> &Element<'buf>
pub fn as_element(&self) -> &Element<'buf>
Return the inner json::Element and discard the version info.
Examples found in repository?
More examples
examples/price_cdr_with_unknown_version.rs (line 90)
77fn print_timezone_warnings(
78 cdr: &cdr::Versioned<'_>,
79 warnings: &warning::Set<timezone::WarningKind>,
80) {
81 if warnings.is_empty() {
82 return;
83 }
84
85 eprintln!("WARN: {} warnings from the timezone search", warnings.len());
86
87 eprintln!(
88 "WARN: {} warnings from the timezone search:\n {}",
89 warnings.len(),
90 warning::SetWriter::new(cdr.as_element(), warnings)
91 );
92}
93
94fn print_pricing_warnings(cdr: &cdr::Versioned<'_>, warnings: &warning::Set<price::WarningKind>) {
95 if warnings.is_empty() {
96 return;
97 }
98
99 eprintln!(
100 "WARN: {} warnings from the linting:\n {}",
101 warnings.len(),
102 warning::SetWriter::new(cdr.as_element(), warnings)
103 );
104}Sourcepub fn as_json_str(&self) -> &'buf str
pub fn as_json_str(&self) -> &'buf str
Return the inner JSON str and discard the version info.
Trait Implementations§
Auto Trait Implementations§
impl<'buf> Freeze for Versioned<'buf>
impl<'buf> RefUnwindSafe for Versioned<'buf>
impl<'buf> Send for Versioned<'buf>
impl<'buf> Sync for Versioned<'buf>
impl<'buf> Unpin for Versioned<'buf>
impl<'buf> UnwindSafe for Versioned<'buf>
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