Skip to main content

Data

Struct Data 

Source
pub struct Data<T>
where T: Default + Clone + PartialEq,
{ /* private fields */ }
Expand description

A generic container for a piece of data, associated with a unique identifier.

Data<T> is a fundamental building block for representing discrete pieces of information within a larger system, such as a context or a causal graph. It wraps a data payload of type T and pairs it with a u64 ID, allowing the data to be uniquely identified and referenced.

The struct derives Clone, so a Data<T> duplicates whenever its payload does. The trait bounds on T keep the payload constructible, duplicable, and comparable.

§Type Parameters

  • T: The type of the data payload. It must be a comparable type satisfying the Default + Clone + PartialEq bounds. Copy is NOT required: it is asked for only by the Adjustable impl, because ArrayGrid is backed by fixed-size arrays. A Data<Vec<f64>> is therefore a valid context node.

Implementations§

Source§

impl<T> Data<T>
where T: Default + Clone + PartialEq,

Source

pub fn new(id: ContextoidId, data: T) -> Self

Trait Implementations§

Source§

impl<T> Adjustable<T> for Data<T>
where T: Default + Copy + Clone + Hash + Eq + PartialEq + PartialOrd + Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T>,

Source§

fn update<const WIDTH: usize, const HEIGHT: usize, const DEPTH: usize, const TIME: usize>( &mut self, array_grid: &ArrayGrid<T, WIDTH, HEIGHT, DEPTH, TIME>, ) -> Result<(), UpdateError>

The default implementation does nothing to keep update optional. Override this method to implement a node update when needed. For a sample implementation, see src/types/context_types/node_types_adjustable
Source§

fn adjust<const WIDTH: usize, const HEIGHT: usize, const DEPTH: usize, const TIME: usize>( &mut self, array_grid: &ArrayGrid<T, WIDTH, HEIGHT, DEPTH, TIME>, ) -> Result<(), AdjustmentError>

The default implementation does nothing to keep adjustment optional. Override this method to implement a node adjustment when needed. Depending on the type of node adjustment, select a 1, 2,3, or 4 dimensional array grid that contains the transformation data to apply to the node. For a sample implementation, see src/types/context_types/node_types_adjustable
Source§

impl<T> Clone for Data<T>
where T: Default + Clone + PartialEq + Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Datable for Data<T>
where T: Default + Clone + PartialEq,

Implements the Datable trait for Data<T>.

This allows Data<T> to be used in contexts where a generic data container is expected, providing methods to get and set the inner data payload.

Source§

type Data = T

Source§

fn get_data(&self) -> Self::Data

Returns the contained data. Read more
Source§

fn set_data(&mut self, value: Self::Data)

Sets or updates the contained data with a new value.
Source§

impl<T> Debug for Data<T>
where T: Default + Clone + PartialEq + Debug,

Source§

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

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

impl<T> Default for Data<T>
where T: Default + Clone + PartialEq + Default,

Source§

fn default() -> Self

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

impl<T> Display for Data<T>
where T: Debug + Default + Clone + PartialEq,

Source§

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

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

impl<T> Identifiable for Data<T>
where T: Default + Clone + PartialEq,

Source§

fn id(&self) -> ContextoidId

Returns the unique id of this item.
Source§

impl<T> PartialEq for Data<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: Storable + Default + Clone + PartialEq> Recordable<DataRecord> for Data<T>

Every storable payload makes its data node recordable. This is the one place a payload’s Storable meets the node’s Recordable.

Source§

fn to_record(&self) -> Result<DataRecord, ProjectionError>

The node as a record.
Source§

fn from_record( id: ContextoidId, record: DataRecord, ) -> Result<Self, ProjectionError>

The node a record describes, under the given identifier.
Source§

impl<T> StructuralPartialEq for Data<T>

Auto Trait Implementations§

§

impl<T> Freeze for Data<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Data<T>
where T: RefUnwindSafe,

§

impl<T> Send for Data<T>
where T: Send,

§

impl<T> Sync for Data<T>
where T: Sync,

§

impl<T> Unpin for Data<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Data<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Data<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<Borrowed> SampleBorrow<Borrowed> for Borrowed

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.