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§
source§impl DataObject
impl DataObject
sourcepub fn init() -> ((u64, u64), (u64, u64))
pub fn init() -> ((u64, u64), (u64, u64))
Initialize global storage of objects. Call only once at startup.
sourcepub fn mirror(q: (u64, u64), r: (u64, u64))
pub fn mirror(q: (u64, u64), r: (u64, u64))
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
👎Deprecated since 0.3.0: please use clone
instead
pub fn duplicate(&self) -> DataObject
clone
insteadReturns 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
👎Deprecated since 0.3.0: please use get_boolean
instead
pub fn get_bool(&self, key: &str) -> bool
get_boolean
insteadReturns the stored value for the given key as a bool
.
sourcepub fn get_i64(&self, key: &str) -> i64
👎Deprecated since 0.3.0: please use get_int
instead
pub fn get_i64(&self, key: &str) -> i64
get_int
insteadReturns the stored value for the given key as an i64
.
sourcepub fn get_f64(&self, key: &str) -> f64
👎Deprecated since 0.3.0: please use get_float
instead
pub fn get_f64(&self, key: &str) -> f64
get_float
insteadReturns the stored value for the given key as an f64
.
sourcepub fn get_boolean(&self, key: &str) -> bool
pub fn get_boolean(&self, key: &str) -> bool
Returns the stored value for the given key as a bool
.
sourcepub fn get_float(&self, key: &str) -> f64
pub fn get_float(&self, key: &str) -> f64
Returns the stored value for the given key as an f64
.
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_str(&mut self, key: &str, val: &str)
👎Deprecated since 0.3.0: please use put_string
instead
pub fn put_str(&mut self, key: &str, val: &str)
put_string
insteadSet the given String
value for the given key.
sourcepub fn put_bool(&mut self, key: &str, val: bool)
👎Deprecated since 0.3.0: please use put_booolean
instead
pub fn put_bool(&mut self, key: &str, val: bool)
put_booolean
insteadSet the given bool
value for the given key.
sourcepub fn put_i64(&mut self, key: &str, val: i64)
👎Deprecated since 0.3.0: please use put_int
instead
pub fn put_i64(&mut self, key: &str, val: i64)
put_int
insteadSet the given i64
value for the given key.
sourcepub fn put_string(&mut self, key: &str, val: &str)
pub fn put_string(&mut self, key: &str, val: &str)
Set the given String
value for the given key.
sourcepub fn put_boolean(&mut self, key: &str, val: bool)
pub fn put_boolean(&mut self, key: &str, val: bool)
Set the given bool
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