pub struct Pricing { /* private fields */ }Expand description
Every model’s pricing, keyed by model id.
Loaded rather than compiled in — see the module documentation.
Implementations§
Source§impl Pricing
impl Pricing
Sourcepub fn from_json(json: &str) -> Result<Self, PricingError>
pub fn from_json(json: &str) -> Result<Self, PricingError>
Read a catalogue from JSON.
§Errors
PricingError::Malformed if the document is not a map of model id to
cost model.
Sourcepub fn to_json(&self) -> Result<String, PricingError>
pub fn to_json(&self) -> Result<String, PricingError>
Render the catalogue back to JSON.
§Errors
PricingError::Malformed if the catalogue cannot be encoded.
Sourcepub fn with(self, model: impl Into<String>, cost: CostModel) -> Self
pub fn with(self, model: impl Into<String>, cost: CostModel) -> Self
Add or replace one model’s pricing.
Sourcepub fn get(&self, model: &str) -> Option<&CostModel>
pub fn get(&self, model: &str) -> Option<&CostModel>
What a model charges, if the catalogue knows it.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Pricing
impl<'de> Deserialize<'de> for Pricing
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Pricing
impl StructuralPartialEq for Pricing
Auto Trait Implementations§
impl Freeze for Pricing
impl RefUnwindSafe for Pricing
impl Send for Pricing
impl Sync for Pricing
impl Unpin for Pricing
impl UnsafeUnpin for Pricing
impl UnwindSafe for Pricing
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
Source§impl<T> Canonical for T
impl<T> Canonical for T
Source§fn canonical_bytes(&self) -> Result<Vec<u8>, CanonicalError>
fn canonical_bytes(&self) -> Result<Vec<u8>, CanonicalError>
The canonical CBOR encoding of this value.