pub struct Quantity<U>where
U: QuantityUnit,{ /* private fields */ }Expand description
A fixed-point decimal value with a unit, constrained by the QuantityUnit
marker U. Encodes to the rich SchemaValue::Quantity.
Clone/Debug/PartialEq/Eq are implemented by hand so the marker type
U itself does not need to implement them.
Implementations§
Source§impl<U> Quantity<U>where
U: QuantityUnit,
impl<U> Quantity<U>where
U: QuantityUnit,
Sourcepub fn new(
mantissa: i64,
scale: i32,
unit: impl Into<String>,
) -> Result<Quantity<U>, FromSchemaError>
pub fn new( mantissa: i64, scale: i32, unit: impl Into<String>, ) -> Result<Quantity<U>, FromSchemaError>
Constructs a quantity, validating the unit against U.
Sourcepub fn from_quantity_value(
value: QuantityValue,
) -> Result<Quantity<U>, FromSchemaError>
pub fn from_quantity_value( value: QuantityValue, ) -> Result<Quantity<U>, FromSchemaError>
Wraps a QuantityValue, validating its unit against U.
pub fn as_quantity_value(&self) -> &QuantityValue
pub fn into_quantity_value(self) -> QuantityValue
Trait Implementations§
Source§impl<U> Clone for Quantity<U>where
U: QuantityUnit,
impl<U> Clone for Quantity<U>where
U: QuantityUnit,
Source§impl<U> Debug for Quantity<U>where
U: QuantityUnit,
impl<U> Debug for Quantity<U>where
U: QuantityUnit,
impl<U> Eq for Quantity<U>where
U: QuantityUnit,
Source§impl<U> FromSchema for Quantity<U>where
U: QuantityUnit,
impl<U> FromSchema for Quantity<U>where
U: QuantityUnit,
fn from_value(v: &SchemaValue) -> Result<Quantity<U>, FromSchemaError>
Source§impl<U> FromWire for Quantity<U>where
U: QuantityUnit,
impl<U> FromWire for Quantity<U>where
U: QuantityUnit,
Source§impl<U> IntoSchema for Quantity<U>where
U: QuantityUnit,
impl<U> IntoSchema for Quantity<U>where
U: QuantityUnit,
fn type_id() -> TypeId
fn register_in(_b: &mut SchemaBuilder) -> SchemaType
fn to_value(&self) -> SchemaValue
Source§impl<U> IntoWire for Quantity<U>where
U: QuantityUnit,
impl<U> IntoWire for Quantity<U>where
U: QuantityUnit,
fn write_wire(&self, writer: &mut WireWriter) -> Result<i32, WireError>
fn preflight(&self, _resources: &mut WirePreflight) -> Result<(), WireError>
Source§async fn prepare_wire(&self) -> Result<(), WireError>
async fn prepare_wire(&self) -> Result<(), WireError>
Wrap native stream endpoints without reading from them. This is called
only after the complete value has passed resource preflight.
fn write_result_payload( &self, writer: &mut WireWriter, ) -> Result<Option<i32>, WireError>
Source§impl<U> PartialEq for Quantity<U>where
U: QuantityUnit,
impl<U> PartialEq for Quantity<U>where
U: QuantityUnit,
Source§impl<U> WireSchema for Quantity<U>where
U: QuantityUnit,
impl<U> WireSchema for Quantity<U>where
U: QuantityUnit,
fn append_schema(builder: &mut WireSchemaBuilder) -> i32
const IS_UNIT: bool = false
fn contains_stream(seen: &mut HashSet<&'static str>) -> bool
fn wire_type_id() -> String
Auto Trait Implementations§
impl<U> Freeze for Quantity<U>where
PhantomData<U>: Freeze,
impl<U> RefUnwindSafe for Quantity<U>where
PhantomData<U>: RefUnwindSafe,
impl<U> Send for Quantity<U>where
PhantomData<U>: Send,
impl<U> Sync for Quantity<U>where
PhantomData<U>: Sync,
impl<U> Unpin for Quantity<U>where
PhantomData<U>: Unpin,
impl<U> UnsafeUnpin for Quantity<U>where
PhantomData<U>: UnsafeUnpin,
impl<U> UnwindSafe for Quantity<U>where
PhantomData<U>: UnwindSafe,
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