Data

Struct Data 

Source
pub struct Data<T>
where T: Default + Copy + 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 is designed to be lightweight and efficient, deriving Copy and Clone to allow for easy duplication. The trait bounds on T ensure that the contained data is also simple and value-like.

§Type Parameters

  • T: The type of the data payload. It must be a simple, copyable, and comparable type, satisfying the Default + Copy + Clone + Hash + Eq + PartialEq bounds.

Implementations§

Source§

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

Source

pub fn new(id: u64, 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 + Copy + Clone + PartialEq + Clone,

Source§

fn clone(&self) -> Data<T>

Returns a duplicate of the value. Read more
1.0.0 · 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 + Copy + 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 + Copy + 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 + Copy + Clone + PartialEq + Default,

Source§

fn default() -> Data<T>

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

impl<T> Display for Data<T>
where T: Debug + Default + Copy + 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 + Copy + Clone + PartialEq,

Source§

fn id(&self) -> u64

Source§

impl<T> PartialEq for Data<T>

Source§

fn eq(&self, other: &Data<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

Source§

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

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> 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<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 = 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>,

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

impl<T> Satisfies<NoConstraint> for T