MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / stable_node_id

Method stable_node_id

node-graph/graph-craft/src/proto.rs:155–169  ·  view source on GitHub ↗

A stable node ID is a hash of a node that should stay constant. This is used in order to remove duplicates from the graph. In the case of `skip_deduplication`, the `document_node_path` is also hashed in order to avoid duplicate monitor nodes from being removed (which would make it impossible to load thumbnails).

(&self)

Source from the content-addressed store, hash-verified

153 /// A stable node ID is a hash of a node that should stay constant. This is used in order to remove duplicates from the graph.
154 /// In the case of `skip_deduplication`, the `document_node_path` is also hashed in order to avoid duplicate monitor nodes from being removed (which would make it impossible to load thumbnails).
155 pub fn stable_node_id(&self) -> Option<NodeId> {
156 use std::hash::Hasher;
157 let mut hasher = rustc_hash::FxHasher::default();
158
159 self.identifier.as_str().hash(&mut hasher);
160 self.construction_args.cache_hash(&mut hasher);
161 if self.skip_deduplication {
162 self.original_location.path.hash(&mut hasher);
163 }
164
165 std::mem::discriminant(&self.call_argument).hash(&mut hasher);
166 self.call_argument.hash(&mut hasher);
167
168 Some(NodeId(hasher.finish()))
169 }
170
171 /// Construct a new [`ProtoNode`] with the specified construction args and a `ClonedNode` implementation.
172 pub fn value(value: ConstructionArgs, path: Vec<NodeId>) -> Self {

Callers 1

Calls 5

NodeIdClass · 0.50
hashMethod · 0.45
as_strMethod · 0.45
cache_hashMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected