Enum ndata::data::Data

source ·
pub enum Data {
    DObject(usize),
    DArray(usize),
    DBytes(usize),
    DString(String),
    DBoolean(bool),
    DFloat(f64),
    DInt(i64),
    DNull,
}
Expand description

Represents an NData value

DObject, DArray, and DBytes are considered instances and the clone() function will return a reference to the same instance.

Variants§

§

DObject(usize)

Represents an existing instance of ndata::dataobject::DataObject, where data_ref is the value of the DataObject’s data_ref field.

let d = Data::DObject(data_ref);
§

DArray(usize)

Represents an existing instance of ndata::dataobject::DataArray, where data_ref is the value of the DataArray’s data_ref field.

let d = Data::DArray(data_ref);
§

DBytes(usize)

Represents an existing instance of ndata::dataobject::DataBytes, where data_ref is the value of the DataBytes’s data_ref field.

let d = Data::DBytes(data_ref);
§

DString(String)

Contains a String value

let d = Data::DString("hello world".to_owned());
§

DBoolean(bool)

Contains a bool value

let d = Data::DBoolean(true);
§

DFloat(f64)

Contains an f64 value

let d = Data::DFloat(99.99);
§

DInt(i64)

Contains an i64 value

let d = Data::DInt(99);
§

DNull

Contains no value

let d = Data::DNull;

Implementations§

source§

impl Data

source

pub fn is_number(&self) -> bool

Returns true if the value is of type DInt or DFloat.

source

pub fn is_int(&self) -> bool

Returns true if the value is of type DInt.

source

pub fn is_float(&self) -> bool

Returns true if the value is of type DFloat.

source

pub fn is_string(&self) -> bool

Returns true if the value is of type DString.

source

pub fn is_boolean(&self) -> bool

Returns true if the value is of type DBoolean.

source

pub fn is_object(&self) -> bool

Returns true if the value is of type DObject.

source

pub fn is_array(&self) -> bool

Returns true if the value is of type DArray.

source

pub fn is_bytes(&self) -> bool

Returns true if the value is of type DBytes.

source

pub fn is_null(self) -> bool

Returns true if the value is of type DNull.

source

pub fn int(&self) -> i64

Returns the underlying i64 value, or panics if not DInt.

source

pub fn float(&self) -> f64

Returns the underlying f64 value, or panics if not DFloat.

source

pub fn boolean(&self) -> bool

Returns the underlying bool value, or panics if not DBoolean.

source

pub fn string(&self) -> String

Returns the underlying String value, or panics if not DString.

source

pub fn object(&self) -> DataObject

Returns a new DataObject representing the underlying object instance, or panics if not DObject.

source

pub fn array(&self) -> DataArray

Returns a new DataArray representing the underlying array instance, or panics if not DArray.

source

pub fn bytes(&self) -> DataBytes

Returns a new DataBytes representing the underlying byte buffer instance, or panics if not DBytes.

source

pub fn as_string(a: Data) -> String

Returns a String representation of the underlying value.

source

pub fn equals(a: Data, b: Data) -> bool

Trait Implementations§

source§

impl Clone for Data

source§

fn clone(&self) -> Self

Returns a copy of the value.

Since DObject, DArray, and DBytes are references to instances, the resulting Data will point to the same instance as the original.

1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Data

source§

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

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

impl Default for Data

The default for ndata.Data is DNull.

source§

fn default() -> Data

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

Auto Trait Implementations§

§

impl RefUnwindSafe for Data

§

impl Send for Data

§

impl Sync for Data

§

impl Unpin for Data

§

impl UnwindSafe for Data

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> 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,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.