pub struct RateTable { /* private fields */ }Expand description
us-east-1 rates, pinned to when they were read and where from.
The three booleans and the absent increment are documented facts rather than settings, and they are fields because each one is a mistake someone would otherwise make in arithmetic: blending vCPU into a GB-second, adding a per-invoke charge by analogy with Lambda Functions, rounding a 200 ms exec up to a 1-second increment, or subtracting a free tier that does not exist.
§Why the rate fields are private (COST-9)
The Python’s RateTable was a plain frozen dataclass, so anyone could construct
one — which is how pricing.py’s ARM refusal ended up guarding only the fetch
path. Here the five rates are private and there are exactly two ways to obtain a
table: the pinned pinned_rates, and RateTable::from_catalog, which refuses a
catalog missing its ARM compute line rather than substituting the x86 one. So
“compute is priced from the ARM rate” is a property of the type rather than of a
code path that can be bypassed.
Implementations§
Source§impl RateTable
impl RateTable
Sourcepub fn region(&self) -> &Region
pub fn region(&self) -> &Region
The region these rates price.
Not a cosmetic label: eu-west-1 is 5.3% over us-east-1 on compute and 19% on snapshot storage, and ap-northeast-1 is 16.4% and 20%. A caller in Tokyo reading the us-east-1 table understates their snapshot write bill by 22.6%, which is not a rounding difference and would never show up as staleness.
Sourcepub fn source_url(&self) -> &str
pub fn source_url(&self) -> &str
Where these figures came from, as an instruction a reader can act on.
Sourcepub fn retrieved(&self) -> CalendarDate
pub fn retrieved(&self) -> CalendarDate
When they were read.
Sourcepub fn vcpu_second(&self) -> Decimal
pub fn vcpu_second(&self) -> Decimal
Per vCPU-second, billed separately from memory.
Sourcepub fn gb_second(&self) -> Decimal
pub fn gb_second(&self) -> Decimal
Per GB-second of baseline memory, billed separately from vCPU.
Sourcepub fn storage_gb_month(&self) -> Decimal
pub fn storage_gb_month(&self) -> Decimal
Per GB-month of snapshot storage.
The one derived figure: the Pricing API quotes this per GB-hour, and this
table holds per GB-month. See HOURS_PER_MONTH.
Sourcepub fn snapshot_read_gb(&self) -> Decimal
pub fn snapshot_read_gb(&self) -> Decimal
Per GB read on a launch or a resume.
Sourcepub fn snapshot_write_gb(&self) -> Decimal
pub fn snapshot_write_gb(&self) -> Decimal
Per GB written on a suspend. Roughly 2.5x the read rate, so a cycle costed with one rate twice is wrong in whichever direction it picked.
Sourcepub fn minimum_retention(&self) -> Duration
pub fn minimum_retention(&self) -> Duration
The documented storage minimum (COST-8).
On the rate row itself, so it applies to anything stored there.
Sourcepub fn minimum_retention_days(&self) -> u64
pub fn minimum_retention_days(&self) -> u64
The same minimum in whole days, which is the unit the note on a floored line item quotes.
Here rather than as an as_secs() / 86_400 at the one call site, because that
spelling is a second place the seconds-to-days convention lives: the field is
the only thing that knows how long the window is, and a division written beside
the message would keep saying “7-day” after a rate row moved to a fortnight.
Truncating rather than rounding is deliberate — a floor quoted as longer than it
is would overstate the charge a reader is being told about.
Sourcepub fn per_request(&self) -> Decimal
pub fn per_request(&self) -> Decimal
MicroVMs bills per second with no per-request charge.
A method returning a constant rather than a field, because it is a documented fact and not a table entry someone could edit into a different claim. The Lambda free tier is Functions-only and no MicroVMs free tier is published.
Sourcepub fn bills_vcpu_and_memory_separately(&self) -> bool
pub fn bills_vcpu_and_memory_separately(&self) -> bool
vCPU and memory are two line items, as the pricing page prices them.
A blended GB-second figure cannot be reconciled against a Cost Explorer breakdown that keeps them apart.
Sourcepub fn minimum_billing_increment(&self) -> Option<Duration>
pub fn minimum_billing_increment(&self) -> Option<Duration>
The minimum billing increment, which is not published.
None means not published, not “one second”. Nothing here rounds a duration
up, because inventing an increment would overcharge every short exec in a
report and there is no source for one.
Sourcepub fn age_days(&self, today: CalendarDate) -> i64
pub fn age_days(&self, today: CalendarDate) -> i64
How many days ago these rates were read.
Sourcepub fn is_stale(&self, today: CalendarDate) -> bool
pub fn is_stale(&self, today: CalendarDate) -> bool
Whether the table is past STALE_AFTER_DAYS (COST-7).
Sourcepub fn staleness(&self, today: CalendarDate) -> Option<String>
pub fn staleness(&self, today: CalendarDate) -> Option<String>
The warning text, or None when the table is fresh.
Text rather than a bool because the warning has to survive into whatever renders it, carrying the retrieval date and the URL — a figure copied out of a terminal loses everything else.
Source§impl RateTable
impl RateTable
Sourcepub fn from_catalog(
region: Region,
source_url: impl Into<String>,
retrieved: CalendarDate,
catalog: &RateCatalog,
) -> Result<RateTable, Error>
pub fn from_catalog( region: Region, source_url: impl Into<String>, retrieved: CalendarDate, catalog: &RateCatalog, ) -> Result<RateTable, Error>
A table for one region, built from a catalog — or a refusal (COST-9).
All or nothing. A partial table would price a run at less than it costs, and the caller has no way to see which field was quietly left at a stale value.
Four ways this refuses, each a way the catalog could change and still parse: a missing ARM compute line whose x86 sibling is present (the substitution that would look entirely healthy and inflate every estimate by 17.9%), a missing line with no sibling, a restated unit, and two products where there was one.
Trait Implementations§
impl Eq for RateTable
impl StructuralPartialEq for RateTable
Auto Trait Implementations§
impl Freeze for RateTable
impl RefUnwindSafe for RateTable
impl Send for RateTable
impl Sync for RateTable
impl Unpin for RateTable
impl UnsafeUnpin for RateTable
impl UnwindSafe for RateTable
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