pub struct Decimal(/* private fields */);Expand description
An OCPP number.
Backed by f64, because that is what the schemas say ("type": "number") and every OCPP
number is a sensor reading — watts, amperes, watt-hours, percentages.
Serialized in serde_json’s float_roundtrip mode, so the value survives exactly
(1.15 never drifts to 1.1499999999999999) but the spelling does not: 1.10 comes back
as 1.1. Non-finite values are refused at serialization rather than becoming null.
Money is the exception, in the 2.1 Tariff and Cost block. Work in the smallest currency
unit and call Decimal::get at the boundary, or carry your own decimal type.
Implementations§
Trait Implementations§
impl Copy for Decimal
Source§impl<'de> Deserialize<'de> for Decimal
impl<'de> Deserialize<'de> for Decimal
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialOrd for Decimal
impl PartialOrd for Decimal
impl StructuralPartialEq for Decimal
Source§impl Validate for Decimal
impl Validate for Decimal
Source§fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations)
fn validate_at(&self, path: &mut ValidationPath, out: &mut Violations)
Appends this value’s violations to
out, relative to path.Auto Trait Implementations§
impl Freeze for Decimal
impl RefUnwindSafe for Decimal
impl Send for Decimal
impl Sync for Decimal
impl Unpin for Decimal
impl UnsafeUnpin for Decimal
impl UnwindSafe for Decimal
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