pub enum DataValue {
Number(f64),
Text(String),
Bool(bool),
Null,
List(Vec<DataValue>),
Object(Vec<(String, DataValue)>),
}Expand description
ECharts data is loosely typed: a point can be a bare number, a
[name, value] pair, or an object with named fields. The chart crate
keeps the same flexibility, so an existing ECharts dataset can be
ported without reshaping it.
Variants§
Number(f64)
A numeric value.
Text(String)
A text value.
Bool(bool)
A boolean value.
Null
An explicit null.
List(Vec<DataValue>)
A list of values.
Object(Vec<(String, DataValue)>)
An object with named fields, in insertion order.
Implementations§
Source§impl DataValue
Inherent implementation of DataValue.
impl DataValue
Inherent implementation of DataValue.
Sourcepub fn as_number(&self) -> Option<f64>
pub fn as_number(&self) -> Option<f64>
Returns the numeric value, when the value is a number.
§Returns
Option<f64>-Some(...)on success,Noneotherwise.
Sourcepub fn to_number(&self) -> Option<f64>
pub fn to_number(&self) -> Option<f64>
Returns the numeric value, parsing a text value when needed.
§Returns
Option<f64>-Some(...)on success,Noneotherwise.
Sourcepub fn as_text(&self) -> Option<&str>
pub fn as_text(&self) -> Option<&str>
Returns the text value, when the value is text.
§Returns
Option<&str>-Some(...)on success,Noneotherwise.
Sourcepub fn as_list(&self) -> Option<&[DataValue]>
pub fn as_list(&self) -> Option<&[DataValue]>
Returns the list value, when the value is a list.
§Returns
Option<&[DataValue]>-Some(...)on success,Noneotherwise.
Sourcepub fn as_object(&self) -> Option<&[(String, DataValue)]>
pub fn as_object(&self) -> Option<&[(String, DataValue)]>
Returns the object value, when the value is an object.
§Returns
Option<&[(String, DataValue)]>-Some(...)on success,Noneotherwise.
Trait Implementations§
impl StructuralPartialEq for DataValue
Auto Trait Implementations§
impl Freeze for DataValue
impl RefUnwindSafe for DataValue
impl Send for DataValue
impl Sync for DataValue
impl Unpin for DataValue
impl UnsafeUnpin for DataValue
impl UnwindSafe for DataValue
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