Skip to main content

fact_to_stable_json

Function fact_to_stable_json 

Source
pub fn fact_to_stable_json(fact: &Fact) -> Result<Value, HashError>
Expand description

重导出 tier1 的哈希算法(单一真相源)

所有哈希计算函数均在 evorule_reactor::hash 中实现, 本模块通过 re-export 对外暴露相同的 API。 将 Fact 序列化为稳定的 JSON 格式

使用显式的 JSON 序列化而非依赖 Debug trait,确保:

  1. 序列化格式不受 Rust 版本或 Debug 实现变更影响
  2. 字段顺序固定且可预测(serde_json::Map 基于 BTreeMap,字母序)
  3. 跨版本兼容性有保障

§参数

  • fact: 要序列化的事实

§返回值

  • Ok(serde_json::Value): 序列化后的 JSON 值
  • Err(HashError): 序列化失败