onq/core/qdu.rs
1//! ONQ qubit representation data structure
2
3use super::error::QduId;
4use std::fmt;
5
6/// Represents a Qualitative Distinction Unit (QDU).
7/// This is the fundamental unit of distinction derived from
8/// initial derivations (Existence, Boundary, Information Necessity).
9/// Each QDU carries the potential for state/quality.
10///
11/// Analogy: Conceptually analogous to a qubit in quantum computing, but its
12/// properties and behavior are strictly defined by derivations.
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct Qdu {
15 /// Unique identifier derived from its creation context within a simulation.
16 /// This simulates the uniqueness arising from the history and position
17 /// within the reference structures.
18 id: QduId,
19}
20
21impl Qdu {
22 /// Creates a new QDU instance.
23 ///
24 /// Note: Ensuring the uniqueness of `id_val` within a given simulation
25 /// context (e.g., within a `ReferenceFrame` or `Simulator`) is crucial
26 /// and the responsibility of the calling code managing QDU allocation.
27 /// This reflects the principle that distinction arises within a context.
28 #[allow(dead_code)]
29 pub(crate) fn new(id_val: u64) -> Self {
30 //Marked pub(crate) as direct creation might be managed internally.
31 // A public factory method might exist elsewhere (e.g., on Simulator or Frame).
32 Self { id: QduId(id_val) }
33 }
34
35 /// Gets the unique identifier of this QDU.
36 pub fn id(&self) -> QduId {
37 self.id
38 }
39}
40
41impl fmt::Display for Qdu {
42 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43 write!(f, "{}", self.id) // Display QDU by its ID
44 }
45}