Skip to main content

DataValue

Enum DataValue 

Source
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.

Source

pub fn as_number(&self) -> Option<f64>

Returns the numeric value, when the value is a number.

§Returns
  • Option<f64> - Some(...) on success, None otherwise.
Source

pub fn to_number(&self) -> Option<f64>

Returns the numeric value, parsing a text value when needed.

§Returns
  • Option<f64> - Some(...) on success, None otherwise.
Source

pub fn as_text(&self) -> Option<&str>

Returns the text value, when the value is text.

§Returns
  • Option<&str> - Some(...) on success, None otherwise.
Source

pub fn as_list(&self) -> Option<&[DataValue]>

Returns the list value, when the value is a list.

§Returns
  • Option<&[DataValue]> - Some(...) on success, None otherwise.
Source

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, None otherwise.
Source

pub fn get(&self, name: &str) -> Option<&DataValue>

Looks up a named field of an object value.

§Arguments
  • &str - Shared reference to a str.
§Returns
  • Option<&DataValue> - Some(...) on success, None otherwise.
Source

pub fn get_mut(&mut self, name: &str) -> Option<&mut DataValue>

Looks up a named field of an object value, mutably.

§Arguments
  • &str - Shared reference to a str.
§Returns
  • Option<&mut DataValue> - Some(...) on success, None otherwise.
Source

pub fn as_object_mut(&mut self) -> Option<&mut [(String, DataValue)]>

Returns the object value, mutably, when the value is an object.

§Returns
  • Option<&mut [(String, DataValue)]> - Some(...) on success, None otherwise.
Source

pub fn is_null(&self) -> bool

Returns true when the value carries no data.

§Returns
  • bool - A boolean.

Trait Implementations§

Source§

impl Clone for DataValue

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DataValue

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<&str> for DataValue

From conversion into DataValue.

Source§

fn from(value: &str) -> Self

Converts a &str into DataValue.

§Arguments
  • &str - Input value to convert from.
Source§

impl From<String> for DataValue

From conversion into DataValue.

Source§

fn from(value: String) -> Self

Converts a String into DataValue.

§Arguments
  • String - Input value to convert from.
Source§

impl From<Vec<DataValue>> for DataValue

From conversion into DataValue.

Source§

fn from(value: Vec<DataValue>) -> Self

Lifts a Vec<DataValue> into DataValue.

§Arguments
  • Vec<DataValue> - Input value to convert from.
Source§

impl From<bool> for DataValue

From conversion into DataValue.

Source§

fn from(value: bool) -> Self

Converts a bool into DataValue.

§Arguments
  • bool - Input value to convert from.
Source§

impl From<f64> for DataValue

From conversion into DataValue.

Source§

fn from(value: f64) -> Self

Converts a f64 into DataValue.

§Arguments
  • f64 - Input value to convert from.
Source§

impl From<i32> for DataValue

From conversion into DataValue.

Source§

fn from(value: i32) -> Self

Converts a i32 into DataValue.

§Arguments
  • i32 - Input value to convert from.
Source§

impl PartialEq for DataValue

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DataValue

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more