arc-graph-core 0.2.0

Framework-free knowledge-graph model for arc-graph: nodes, typed kinds, weighted edges, adjacency index, filter/search and JSON/CSV import.
Documentation
//! 稳定 ID:序列化与筛选回放依赖 ID 不随存储位置变化。与 arc-flow-core 的
//! `NodeId` / `EdgeId` 数值不互通(两套图是不同领域),前缀区分便于日志排障。

use serde::{Deserialize, Serialize};
use std::fmt;

macro_rules! id_type {
    ($name:ident, $prefix:literal) => {
        #[derive(
            Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize,
        )]
        #[serde(transparent)]
        pub struct $name(pub u64);

        impl $name {
            /// 原始数值(序列化 / CSV 列使用)。
            pub fn raw(self) -> u64 {
                self.0
            }
        }

        impl fmt::Display for $name {
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                write!(f, concat!($prefix, "{}"), self.0)
            }
        }
    };
}

id_type!(NodeId, "kn");
id_type!(EdgeId, "ke");
id_type!(KindId, "kt");