[][src]Struct raystack::Number

pub struct Number { /* fields omitted */ }

A Haystack Number, encapsulating a scalar value and an optional unit value. The unit is represented as a string.

Methods

impl Number[src]

pub fn new(value: f64, unit: Option<String>) -> Self[src]

Create a new Number. If present, the unit should be a valid unit string from Project Haystack's unit database.

pub fn value(&self) -> f64[src]

Return the numeric component of this Number.

pub fn unit(&self) -> Option<&str>[src]

Return the unit component of this Number, if present.

pub fn from_encoded_json_string(
    json_string: &str
) -> Result<Self, ParseNumberError>
[src]

Parse a Number from a number encoded in a JSON string.

Example

use raystack::Number;

let n = Number::new(1.0, Some("pH".to_owned()));
assert_eq!(Number::from_encoded_json_string("n:1.0 pH").unwrap(), n);

Trait Implementations

impl Clone for Number[src]

impl PartialEq<Number> for Number[src]

impl Debug for Number[src]

Auto Trait Implementations

impl Unpin for Number

impl Sync for Number

impl Send for Number

impl UnwindSafe for Number

impl RefUnwindSafe for Number

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> Erased for T

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err