diff --git a/src/ecaps2.rs b/src/ecaps2.rs index fabd2e51..780c62e1 100644 --- a/src/ecaps2.rs +++ b/src/ecaps2.rs @@ -4,6 +4,7 @@ extern crate blake2; use disco::{Feature, Identity, Disco}; use data_forms::DataForm; +use hashes; use hashes::{Hash, parse_hash}; use minidom::Element; @@ -38,6 +39,17 @@ pub fn parse_ecaps2(root: &Element) -> Result { }) } +pub fn serialise(ecaps2: &ECaps2) -> Element { + let mut c = Element::builder("c") + .ns(ns::ECAPS2) + .build(); + for hash in ecaps2.hashes.clone() { + let hash_elem = hashes::serialise(&hash); + c.append_child(hash_elem); + } + c +} + fn compute_item(field: &str) -> Vec { let mut bytes = field.as_bytes().to_vec(); bytes.push(0x1f);