pub enum PriceAnnotationView<'a> {
Unit(&'a AmountData),
Total(&'a AmountData),
UnitIncomplete {
number: Option<&'a str>,
currency: Option<&'a str>,
},
TotalIncomplete {
number: Option<&'a str>,
currency: Option<&'a str>,
},
}Expand description
Typed view of a PriceAnnotationData.
Each arm distinguishes per-unit (@) from total (@@) at the
type level, so a match on the view forces consumers to
handle both cases. This is the recommended way to consume price
annotations — see the docstring on PriceAnnotationData for the
motivating bug.
Variants§
Unit(&'a AmountData)
@ AMOUNT — per-unit price with a complete amount.
Total(&'a AmountData)
@@ AMOUNT — total price with a complete amount.
Consumers that compute prices MUST divide by the posting’s
units.number.abs() to recover the per-unit price. See
rustledger_core::extract_per_unit_price (in the
rustledger-core crate; not linked because that crate is not a
dependency of rustledger-plugin-types).
UnitIncomplete
@ NUMBER / @ CURRENCY — per-unit annotation missing one
or both of (number, currency).
Fields
TotalIncomplete
@@ NUMBER / @@ CURRENCY — incomplete total annotation.
Trait Implementations§
Source§impl<'a> Clone for PriceAnnotationView<'a>
impl<'a> Clone for PriceAnnotationView<'a>
Source§fn clone(&self) -> PriceAnnotationView<'a>
fn clone(&self) -> PriceAnnotationView<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more