use ring::digest; use std::collections::BTreeMap; /// A share's public metadata. #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Default)] pub struct MetaData { /// The tags associated with the share pub tags: BTreeMap, } impl MetaData { /// Construct a new MetaData struct. pub fn new() -> Self { MetaData { tags: BTreeMap::new(), } } /// Construct a new MetaData struct, holding the given tags pub fn with_tags(tags: BTreeMap) -> Self { Self { tags } } pub(crate) fn hash_into(&self, ctx: &mut digest::Context) { for (tag, value) in &self.tags { ctx.update(tag.as_bytes()); ctx.update(b":"); ctx.update(value.as_bytes()); } } }