pub struct PriceAnnotationData {
pub is_total: bool,
pub amount: Option<AmountData>,
pub number: Option<String>,
pub currency: Option<String>,
}Expand description
Price annotation data.
Represents price annotations like @ 100 USD or @@ 1000 USD
(total price).
§Type-safe consumption (recommended)
Use PriceAnnotationData::view to get a PriceAnnotationView
— a typed enum that forces consumers to handle Unit and Total
arms exhaustively at compile time. All new code that needs to
distinguish per-unit from total prices MUST use view() rather
than reading is_total directly.
This struct is the wire format (kept for serialization stability
across the WASM plugin boundary). The view() enum is a shaped
accessor on top.
Pre-refactor (issue #992), the implicit_prices plugin read
posting.price.amount directly and silently ignored is_total,
emitting @@ total amounts as per-unit prices. The fix in #997
added explicit handling, but the type system didn’t catch the bug
originally because nothing forced consumers to read the bool. The
view() enum closes that loop: a missing match arm is a compile
error.
Fields§
§is_total: boolWhether this is a total price (@@) vs per-unit (@).
Prefer PriceAnnotationData::view for new code — reading
this field directly is the bug shape that produced #992
(consumer ignores the field and treats every annotation as
per-unit). The view() enum forces exhaustive handling at
compile time.
amount: Option<AmountData>The price amount (optional for incomplete/empty prices).
number: Option<String>The number only (for incomplete prices).
currency: Option<String>The currency only (for incomplete prices).
Implementations§
Source§impl PriceAnnotationData
impl PriceAnnotationData
Sourcepub fn view(&self) -> PriceAnnotationView<'_>
pub fn view(&self) -> PriceAnnotationView<'_>
Get a typed view that distinguishes per-unit from total at
the type level. Use this for new code that needs to handle
the price differently based on @ vs @@.
Returns one of four variants — a missing match arm at the consumer becomes a compile error, eliminating the class of bug that produced issue #992.
Trait Implementations§
Source§impl Clone for PriceAnnotationData
impl Clone for PriceAnnotationData
Source§fn clone(&self) -> PriceAnnotationData
fn clone(&self) -> PriceAnnotationData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PriceAnnotationData
impl Debug for PriceAnnotationData
Source§impl<'de> Deserialize<'de> for PriceAnnotationData
impl<'de> Deserialize<'de> for PriceAnnotationData
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PriceAnnotationData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PriceAnnotationData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for PriceAnnotationData
impl Serialize for PriceAnnotationData
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for PriceAnnotationData
impl RefUnwindSafe for PriceAnnotationData
impl Send for PriceAnnotationData
impl Sync for PriceAnnotationData
impl Unpin for PriceAnnotationData
impl UnsafeUnpin for PriceAnnotationData
impl UnwindSafe for PriceAnnotationData
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.