pub struct NodeId(/* private fields */);Expand description
Stable source identity shared by registration, diagnostics, and pruning. 注册、诊断和修剪共用的稳定源码身份。
This is a compact 128-bit prefix of SHA-256 for indexing and diagnostics, not a cryptographic signature. Plugin trust must use the full digest and a signature verifier. 这是用于索引和诊断的 SHA-256 128 位短标识,不是密码学签名。插件信任必须 使用完整摘要和签名验证器。
Implementations§
Source§impl NodeId
impl NodeId
Sourcepub const fn from_path(relative_path: &str, declared_name: &str) -> NodeId
pub const fn from_path(relative_path: &str, declared_name: &str) -> NodeId
Hash relative_path + 0x00 + declared_name during constant evaluation.
在常量求值期间散列“相对路径 + 0x00 + 声明名”。
Both slices are separator-folded here; from_namespaced_path explains why
the namespaced entry point folds only its first two components.
这里两个切片都会折叠分隔符;命名空间入口为何只折叠前两个组成部分,见
from_namespaced_path。
Sourcepub const fn from_namespaced_path(
namespace: &str,
relative_path: &str,
declared_name: &str,
) -> NodeId
pub const fn from_namespaced_path( namespace: &str, relative_path: &str, declared_name: &str, ) -> NodeId
Hash a declaration together with the package namespace that owns it. 将声明与拥有它的包命名空间一起散列,避免不同库的相对路径串库。
Examples found in repository?
36fn snapshot(namespace: &str, index: usize, parent: NodeId) -> RegistrationSnapshot {
37 let kind = format!("Face{index}");
38 RegistrationSnapshot {
39 namespace: namespace.to_owned(),
40 id: NodeId::from_namespaced_path(namespace, &format!("scale/{index}.rs"), &kind),
41 parent,
42 kind: kind.clone(),
43 preset: "default".to_owned(),
44 parts: String::new(),
45 params: String::new(),
46 handle: kind.clone(),
47 stable_name: None,
48 name: OwnedLocalizedText {
49 zh: kind.clone(),
50 en: kind.clone(),
51 },
52 summary: OwnedLocalizedText {
53 zh: String::new(),
54 en: String::new(),
55 },
56 exports: Vec::new(),
57 needs_registry: false,
58 registry_name: format!("face-{index}"),
59 getting_from_other_registry: None,
60 registry_rule_path: "<scale-audit>".to_owned(),
61 registry_rule: OwnedRegistrationRule {
62 required_preset: None,
63 required_parts: Vec::new(),
64 required_exports: Vec::new(),
65 required_handle_traits: Vec::new(),
66 required_part_traits: Vec::new(),
67 },
68 admission: OwnedAdmission {
69 allowed_paths: Vec::new(),
70 denied_paths: Vec::new(),
71 },
72 requires: Vec::new(),
73 provides: Vec::new(),
74 contract: OwnedObjectContract {
75 required_parts: Vec::new(),
76 provided_parts: Vec::new(),
77 },
78 flow: OwnedFlowContract::none(),
79 flow_provider: None,
80 handle_traits: Vec::new(),
81 part_traits: Vec::new(),
82 runtime_checks: Vec::new(),
83 plugin: None,
84 source: OwnedSourceLocation {
85 file: format!("scale/{index}.rs"),
86 line: 1,
87 column: 1,
88 function: kind,
89 },
90 }
91}Sourcepub const fn from_bytes(input: &[u8]) -> NodeId
pub const fn from_bytes(input: &[u8]) -> NodeId
Hash one byte slice; primarily useful for standard-vector tests. 散列单个字节切片,主要用于标准向量测试。
Sourcepub const fn into_bytes(self) -> [u8; 16]
pub const fn into_bytes(self) -> [u8; 16]
The raw 128-bit identity, round-trippable through from_raw at build time.
原始 128 位身份,构建期可经 from_raw 还原。
Sourcepub const fn pruning_table(self) -> [u64; 4096]
pub const fn pruning_table(self) -> [u64; 4096]
Produce a node-specific compile-time payload for pruning verification. 为修剪验证生成节点专属的编译期负载。
The table is emitted only when the owning node’s probe is reached. 只有触达所属节点探针时,这张表才会进入最终产物。