Struct ndata::dataarray::DataArray

source ·
pub struct DataArray {
    pub data_ref: usize,
}
Expand description

Represents an array of type ndata.Data.

Fields§

§data_ref: usize

The pointer to the array in the array heap.

Implementations§

source§

impl DataArray

source

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

Initialize global storage of arrays. 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 arrays from another process. Call only once at startup.

source

pub fn new() -> DataArray

Create a new (empty) array.

source

pub fn get(data_ref: usize) -> DataArray

Get a reference to the array from the heap

source

pub fn incr(&self)

Increase the reference count for this DataArray.

source

pub fn decr(&self)

Decrease the reference count for this DataArray.

source

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

Create a new DataArray from a JSON string.

source

pub fn to_string(&self) -> String

Create a JSON string from a DataArray.

source

pub fn duplicate(&self) -> DataArray

👎Deprecated since 0.3.0: please use clone instead

Returns a new DataArray that points to the same underlying array instance.

source

pub fn shallow_copy(self) -> DataArray

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

source

pub fn deep_copy(&self) -> DataArray

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

source

pub fn len(&self) -> usize

Returns the length of the array.

source

pub fn index_of(&self, b: Data) -> i64

Returns the index of a Data in the array

source

pub fn push_unique(&self, b: Data) -> bool

Push data if not already in array

source

pub fn remove_data(&self, b: Data) -> bool

Returns the index of a Data in the array

source

pub fn get_property(&self, id: usize) -> Data

Returns the indexed value from the array

source

pub fn get_string(&self, id: usize) -> String

Returns the indexed value from the array as a String

source

pub fn get_bool(&self, id: usize) -> bool

👎Deprecated since 0.3.0: please use get_boolean instead

Returns the indexed value from the array as a bool

source

pub fn get_i64(&self, id: usize) -> i64

👎Deprecated since 0.3.0: please use get_int instead

Returns the indexed value from the array as an i64

source

pub fn get_f64(&self, id: usize) -> f64

👎Deprecated since 0.3.0: please use get_float instead

Returns the indexed value from the array as an f64

source

pub fn get_boolean(&self, id: usize) -> bool

Returns the indexed value from the array as a bool

source

pub fn get_int(&self, id: usize) -> i64

Returns the indexed value from the array as an i64

source

pub fn get_float(&self, id: usize) -> f64

Returns the indexed value from the array as an f64

source

pub fn get_array(&self, id: usize) -> DataArray

Returns the indexed value from the array as a DataArray

source

pub fn get_object(&self, id: usize) -> DataObject

Returns the indexed value from the array as a DataObject

source

pub fn get_bytes(&self, id: usize) -> DataBytes

Returns the indexed value from the array as a DataBytes

source

pub fn join(&mut self, a: DataArray)

Append all values from another array

source

pub fn push_property(&mut self, data: Data)

Append the given value to the end of the array

source

pub fn push_str(&mut self, val: &str)

👎Deprecated since 0.3.0: please use push_string instead

Append the given String to the end of the array

source

pub fn push_bool(&mut self, val: bool)

👎Deprecated since 0.3.0: please use push_boolean instead

Append the given bool to the end of the array

source

pub fn push_i64(&mut self, val: i64)

👎Deprecated since 0.3.0: please use push_int instead

Append the given i64 to the end of the array

source

pub fn push_string(&mut self, val: &str)

Append the given String to the end of the array

source

pub fn push_boolean(&mut self, val: bool)

Append the given bool to the end of the array

source

pub fn push_int(&mut self, val: i64)

Append the given i64 to the end of the array

source

pub fn push_float(&mut self, val: f64)

Append the given f64 to the end of the array

source

pub fn push_object(&mut self, o: DataObject)

Append the given DataObject to the end of the array

source

pub fn push_list(&mut self, a: DataArray)

👎Deprecated since 0.1.2: please use push_array instead
source

pub fn push_array(&mut self, a: DataArray)

Append the given DataArray to the end of the array

source

pub fn push_bytes(&mut self, a: DataBytes)

Append the given DataBytes to the end of the array

source

pub fn push_null(&mut self)

Append NULL to the end of the array

source

pub fn set_property(&mut self, id: usize, data: Data)

Replace the indexed value in the array

source

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

👎Deprecated since 0.3.0: please use put_string instead

Replace the indexed value in the array with the given String.

source

pub fn put_bool(&mut self, id: usize, val: bool)

👎Deprecated since 0.3.0: please use put_boolean instead

Replace the indexed value in the array with the given bool.

source

pub fn put_i64(&mut self, id: usize, val: i64)

👎Deprecated since 0.3.0: please use put_int instead

Replace the indexed value in the array with the given i64.

source

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

Replace the indexed value in the array with the given String.

source

pub fn put_boolean(&mut self, id: usize, val: bool)

Replace the indexed value in the array with the given bool.

source

pub fn put_int(&mut self, id: usize, val: i64)

Replace the indexed value in the array with the given i64.

source

pub fn put_float(&mut self, id: usize, val: f64)

Replace the indexed value in the array with the given f64.

source

pub fn put_object(&mut self, id: usize, o: DataObject)

Replace the indexed value in the array with the given DataObject.

source

pub fn put_array(&mut self, id: usize, a: DataArray)

Replace the indexed value in the array with the given DataArray.

source

pub fn put_bytes(&mut self, id: usize, a: DataBytes)

Replace the indexed value in the array with the given DataBytes.

source

pub fn put_null(&mut self, id: usize)

Replace the indexed value in the array with NULL.

source

pub fn remove_property(&mut self, id: usize)

Remove the indexed value from the array

source

pub fn pop_property(&mut self, id: usize) -> Data

Pop the indexed value from the array

source

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

DO NOT USE

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

source

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

Returns this array as a Vec<Data>.

source

pub fn print_heap()

Prints the arrays currently stored in the heap

source

pub fn gc()

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

Trait Implementations§

source§

impl Clone for DataArray

source§

fn clone(&self) -> Self

Returns another DataArray 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 DataArray

source§

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

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

impl Default for DataArray

source§

fn default() -> DataArray

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

impl Drop for DataArray

Adds this DataArray’s data_ref to ODROP. Reference counts are adjusted when DataArray::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.