Skip to main content

deep_causality_context/traits/contextuable/
datable.rs

1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5
6use deep_causality_core::Identifiable;
7
8/// Represents data-bearing entities in a context graph.
9///
10/// This trait marks nodes that carry domain-specific data
11/// relevant to inference, observation, or explanation. It extends
12/// [`Identifiable`] to ensure that each instance has a unique identity.
13///
14/// This trait is intentionally left minimal to allow full flexibility
15/// in how data is modeled. You may wrap sensor input, encoded strings,
16/// discrete values, or even external references.
17///
18pub trait Datable: Identifiable {
19    type Data;
20
21    /// Returns the contained data.
22    ///
23    /// If `Self::Data` is `Copy`, this will typically return a copy. Otherwise, it may
24    /// return a clone or a new instance depending on the implementation.
25    fn get_data(&self) -> Self::Data;
26
27    /// Sets or updates the contained data with a new value.
28    fn set_data(&mut self, value: Self::Data);
29}