pub struct DataObject {
    pub data_ref: usize,
}
Expand description

Represents a map of type <String, ndata.Data>.

Fields§

§data_ref: usize

The pointer to the object in the object heap.

Implementations§

source§

impl DataObject

source

pub fn init() -> ((u64, u64), (u64, u64))

Initialize global storage of objects. Call only once at startup.

source

pub fn share() -> ((u64, u64), (u64, u64))

source

pub fn mirror(q: (u64, u64), r: (u64, u64))

Mirror global storage of objects from another process. Call only once at startup.

source

pub fn new() -> DataObject

Create a new (empty) object.

source

pub fn get(data_ref: usize) -> DataObject

Get a reference to the object from the heap

source

pub fn incr(&self)

Increase the reference count for this DataObject.

source

pub fn decr(&self)

Decrease the reference count for this DataObject.

source

pub fn from_string(s: &str) -> DataObject

Create a new DataObject from a JSON string.

source

pub fn to_string(&self) -> String

Create a JSON string from a DataObject.

source

pub fn duplicate(&self) -> DataObject

👎Deprecated since 0.3.0: please use clone instead

Returns a new DataObject that points to the same underlying object instance.

source

pub fn shallow_copy(&self) -> DataObject

Returns a new DataObject that points to a new object instance, which contains the same underlying data as the original.

source

pub fn deep_copy(&self) -> DataObject

Returns a new DataObject that points to a new object instance, which contains a recursively deep copy of the original underlying data.

source

pub fn has(&self, key: &str) -> bool

Returns true if this object contains the given key.

source

pub fn keys(self) -> Vec<String>

Returns a list (Vec<String>) of the keys in this object.

source

pub fn get_property(&self, key: &str) -> Data

Returns the stored value for the given key.

source

pub fn get_string(&self, key: &str) -> String

Returns the stored value for the given key as a String.

source

pub fn get_bool(&self, key: &str) -> bool

👎Deprecated since 0.3.0: please use get_boolean instead

Returns the stored value for the given key as a bool.

source

pub fn get_i64(&self, key: &str) -> i64

👎Deprecated since 0.3.0: please use get_int instead

Returns the stored value for the given key as an i64.

source

pub fn get_f64(&self, key: &str) -> f64

👎Deprecated since 0.3.0: please use get_float instead

Returns the stored value for the given key as an f64.

source

pub fn get_boolean(&self, key: &str) -> bool

Returns the stored value for the given key as a bool.

source

pub fn get_int(&self, key: &str) -> i64

Returns the stored value for the given key as an i64.

source

pub fn get_float(&self, key: &str) -> f64

Returns the stored value for the given key as an f64.

source

pub fn get_object(&self, key: &str) -> DataObject

Returns the stored value for the given key as a DataObject.

source

pub fn get_array(&self, key: &str) -> DataArray

Returns the stored value for the given key as a DataArray.

source

pub fn get_bytes(&self, key: &str) -> DataBytes

Returns the stored value for the given key as a DataBytes.

source

pub fn remove_property(&mut self, key: &str)

Remove the value from the object for the given key.

source

pub fn set_property(&mut self, key: &str, data: Data)

Set the given value for the given key.

source

pub fn put_str(&mut self, key: &str, val: &str)

👎Deprecated since 0.3.0: please use put_string instead

Set the given String value for the given key.

source

pub fn put_bool(&mut self, key: &str, val: bool)

👎Deprecated since 0.3.0: please use put_booolean instead

Set the given bool value for the given key.

source

pub fn put_i64(&mut self, key: &str, val: i64)

👎Deprecated since 0.3.0: please use put_int instead

Set the given i64 value for the given key.

source

pub fn put_string(&mut self, key: &str, val: &str)

Set the given String value for the given key.

source

pub fn put_boolean(&mut self, key: &str, val: bool)

Set the given bool value for the given key.

source

pub fn put_int(&mut self, key: &str, val: i64)

Set the given i64 value for the given key.

source

pub fn put_float(&mut self, key: &str, val: f64)

Set the given f64 value for the given key.

source

pub fn put_object(&mut self, key: &str, o: DataObject)

Set the given DataObject value for the given key.

source

pub fn put_list(&mut self, key: &str, a: DataArray)

👎Deprecated since 0.1.2: please use put_array instead
source

pub fn put_array(&mut self, key: &str, a: DataArray)

Set the given DataArray value for the given key.

source

pub fn put_bytes(&mut self, key: &str, a: DataBytes)

Set the given DataBytes value for the given key.

source

pub fn put_null(&mut self, key: &str)

Set the for the given key to DNull.

source

pub fn delete( oheap: &mut Heap<HashMap<String, Data>>, data_ref: usize, aheap: &mut Heap<Vec<Data>> )

DO NOT USE

Reduces the reference count for this object by one, as well as the reference counts of any objects, arrays, or byte buffers contained in this object. This function should only be used externally by DataArray::gc().

source

pub fn objects(&self) -> Vec<(String, Data)>

Returns the key value pairs in this object as a Vec<String, Data>.

source

pub fn print_heap()

Prints the objects currently stored in the heap

source

pub fn gc()

Perform garbage collection. Objects will not be removed from the heap until DataObject::gc() is called.

Trait Implementations§

source§

impl Clone for DataObject

source§

fn clone(&self) -> Self

Returns another DataObject pointing to the same value.

1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for DataObject

source§

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

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

impl Default for DataObject

source§

fn default() -> DataObject

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

impl Drop for DataObject

Adds this DataObject’s data_ref to ADROP. Reference counts are adjusted when DataObject::gc() is called.

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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