MCPcopy Create free account
hub / github.com/argumentcomputer/ix / hash_data_value

Function hash_data_value

crates/common/src/env.rs:737–765  ·  view source on GitHub ↗
(dv: &DataValue, hasher: &mut blake3::Hasher)

Source from the content-addressed store, hash-verified

735
736/// A dynamically-typed value stored in expression metadata (`KVMap` entries).
737#[derive(Debug, PartialEq, Eq, Clone, Hash)]
738pub enum DataValue {
739 /// A string value.
740 OfString(String),
741 /// A boolean value.
742 OfBool(bool),
743 /// A name value.
744 OfName(Name),
745 /// A natural number value.
746 OfNat(Nat),
747 /// An integer value.
748 OfInt(Int),
749 /// A syntax tree value.
750 OfSyntax(Box<Syntax>),
751}
752
753pub fn hash_data_value(dv: &DataValue, hasher: &mut blake3::Hasher) {
754 hasher.update(&[MDVAL]);
755 match dv {
756 DataValue::OfString(s) => {
757 hasher.update(&[0]);
758 hasher.update(s.as_bytes());
759 },
760 DataValue::OfBool(b) => {
761 hasher.update(&[1]);
762 hasher.update(&[u8::from(*b)]);
763 },
764 DataValue::OfName(name) => {
765 hasher.update(&[2]);
766 hasher.update(name.get_hash().as_bytes());
767 },
768 DataValue::OfNat(n) => {

Callers 3

find_diffFunction · 0.85
mdataMethod · 0.85
meta_hashMethod · 0.85

Calls 4

hash_intFunction · 0.85
hash_syntaxFunction · 0.85
as_bytesMethod · 0.80
get_hashMethod · 0.80

Tested by

no test coverage detected