pub enum Amount {
Estimated(EstimatedUsd),
Unpriced {
reason: String,
},
}Expand description
What a line item’s cost can be (COST-3).
Any consumer that matches on this has to handle the unknown case, which is the
property the whole module rests on. Amount::Unpriced is distinct from
Amount::Estimated(EstimatedUsd::ZERO) on purpose: zero is a claim about the
bill, unpriced is a claim about the documentation.
Variants§
Estimated(EstimatedUsd)
Unpriced
A quantity we can measure but cannot price, because no rate is published.
The reason is a field and not optional, so the line item can say why rather
than just that it cannot. BUILD_UNPRICED_REASON is the one this module
raises.
Implementations§
Source§impl Amount
impl Amount
Sourcepub fn unpriced(reason: impl Into<String>) -> Amount
pub fn unpriced(reason: impl Into<String>) -> Amount
An unpriced amount, with the reason that goes on the line item.
Sourcepub fn estimate(&self) -> Option<EstimatedUsd>
pub fn estimate(&self) -> Option<EstimatedUsd>
The estimate, when there is one.
Returns Option rather than defaulting to zero, which is the same decision
as cli.py’s JSON omitting the usd key entirely for an unpriced line: a
null gets summed as zero by anything permissive, and that is the one
arithmetic this module refuses to enable.
Sourcepub fn unpriced_reason(&self) -> Option<&str>
pub fn unpriced_reason(&self) -> Option<&str>
The reason this could not be priced, when it could not.
Trait Implementations§
impl Eq for Amount
impl StructuralPartialEq for Amount
Auto Trait Implementations§
impl Freeze for Amount
impl RefUnwindSafe for Amount
impl Send for Amount
impl Sync for Amount
impl Unpin for Amount
impl UnsafeUnpin for Amount
impl UnwindSafe for Amount
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 more