Struct ndata::dataobject::DataObject
source · [−]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
sourceimpl DataObject
impl DataObject
sourcepub fn init() -> ((usize, usize), (usize, usize))
pub fn init() -> ((usize, usize), (usize, usize))
Initialize global storage of objects. Call only once at startup.
sourcepub fn mirror(q: (usize, usize), r: (usize, usize))
pub fn mirror(q: (usize, usize), r: (usize, usize))
Mirror global storage of objects from another process. Call only once at startup.
sourcepub fn new() -> DataObject
pub fn new() -> DataObject
Create a new (empty) object.
sourcepub fn get(data_ref: usize) -> DataObject
pub fn get(data_ref: usize) -> DataObject
Get a reference to the object from the heap
sourcepub fn from_string(s: &str) -> DataObject
pub fn from_string(s: &str) -> DataObject
Create a new DataObject from a JSON string.
sourcepub fn duplicate(&self) -> DataObject
pub fn duplicate(&self) -> DataObject
Returns a new DataObject
that points to the same underlying object instance.
sourcepub fn shallow_copy(&self) -> DataObject
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.
sourcepub fn deep_copy(&self) -> DataObject
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.
sourcepub fn get_property(&self, key: &str) -> Data
pub fn get_property(&self, key: &str) -> Data
Returns the stored value for the given key.
sourcepub fn get_string(&self, key: &str) -> String
pub fn get_string(&self, key: &str) -> String
Returns the stored value for the given key as a String
.
sourcepub fn get_bool(&self, key: &str) -> bool
pub fn get_bool(&self, key: &str) -> bool
Returns the stored value for the given key as a bool
.
sourcepub fn get_object(&self, key: &str) -> DataObject
pub fn get_object(&self, key: &str) -> DataObject
Returns the stored value for the given key as a DataObject
.
sourcepub fn get_array(&self, key: &str) -> DataArray
pub fn get_array(&self, key: &str) -> DataArray
Returns the stored value for the given key as a DataArray
.
sourcepub fn get_bytes(&self, key: &str) -> DataBytes
pub fn get_bytes(&self, key: &str) -> DataBytes
Returns the stored value for the given key as a DataBytes
.
sourcepub fn remove_property(&mut self, key: &str)
pub fn remove_property(&mut self, key: &str)
Remove the value from the object for the given key.
sourcepub fn set_property(&mut self, key: &str, data: Data)
pub fn set_property(&mut self, key: &str, data: Data)
Set the given value for the given key.
sourcepub fn put_object(&mut self, key: &str, o: DataObject)
pub fn put_object(&mut self, key: &str, o: DataObject)
Set the given DataObject
value for the given key.
pub fn put_list(&mut self, key: &str, a: DataArray)
put_array
insteadsourcepub fn put_array(&mut self, key: &str, a: DataArray)
pub fn put_array(&mut self, key: &str, a: DataArray)
Set the given DataArray
value for the given key.
sourcepub fn put_bytes(&mut self, key: &str, a: DataBytes)
pub fn put_bytes(&mut self, key: &str, a: DataBytes)
Set the given DataBytes
value for the given key.
sourcepub fn delete(
oheap: &mut Heap<HashMap<String, Data>>,
data_ref: usize,
aheap: &mut Heap<Vec<Data>>
)
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()
.
sourcepub fn objects(&self) -> Vec<(String, Data)>
pub fn objects(&self) -> Vec<(String, Data)>
Returns the key value pairs in this object as a Vec<String, Data>
.
sourcepub fn print_heap()
pub fn print_heap()
Prints the objects currently stored in the heap