pub enum NodeHash {
NotHashed,
Hashed(u64),
}
Expand description
A Hash of the current node state used to signal whether a dependent node needs to update its internal state.
Every edge in a depends
graph tracks the previously observed NodeHash
of
the child node and signals to the dependee whether this has changed since
the last run using the IsDirty trait.
This is used to cache internal computations.
NotHashed
If NotHashed
is used, dependent nodes will never consider previously
observed states equal and will therefore update their internal state
every time they’re resolved. For this reason, it’s recommended that
NotHashed
be used sparingly (in cases where computing a hash of a node’s
state is impossible or costlier than recomputing the dependee’s state).
Whichever implementation is chosen, it’s important to structure graphs so
that the number of nodes and edges to nodes implementing NotHashed
is
kept to a minimum, especially where performance is a concern.
// not equal
assert_ne!(NodeHash::NotHashed, NodeHash::NotHashed);
assert_ne!(NodeHash::NotHashed, NodeHash::Hashed(0));
assert_ne!(NodeHash::Hashed(0), NodeHash::Hashed(1));
// equal
assert_eq!(NodeHash::Hashed(1), NodeHash::Hashed(1));
Variants§
NotHashed
Never equal to another value.
Hashed(u64)
Equal to another value if the internal number is equal.