Skip to main content

NodeId

Struct NodeId 

Source
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

Source

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。

Source

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?
examples/scale_audit.rs (line 40)
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}
Source

pub const fn from_bytes(input: &[u8]) -> NodeId

Hash one byte slice; primarily useful for standard-vector tests. 散列单个字节切片,主要用于标准向量测试。

Source

pub const fn into_bytes(self) -> [u8; 16]

The raw 128-bit identity, round-trippable through from_raw at build time. 原始 128 位身份,构建期可经 from_raw 还原。

Source

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. 只有触达所属节点探针时,这张表才会进入最终产物。

Trait Implementations§

Source§

impl Clone for NodeId

Source§

fn clone(&self) -> NodeId

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for NodeId

Source§

impl Debug for NodeId

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for NodeId

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for NodeId

Source§

impl FromStr for NodeId

Source§

type Err = ParseNodeIdError

The associated error which can be returned from parsing.
Source§

fn from_str(value: &str) -> Result<NodeId, <NodeId as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for NodeId

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for NodeId

Source§

fn cmp(&self, other: &NodeId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for NodeId

Source§

fn eq(&self, other: &NodeId) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for NodeId

Source§

fn partial_cmp(&self, other: &NodeId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for NodeId

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.