From 429abb996d84ac3a1c1d6e1bd2a02a7b24bc8fef Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 23 Apr 2017 18:36:37 +0100 Subject: [PATCH] ecaps2: Implement serialise. --- src/ecaps2.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ecaps2.rs b/src/ecaps2.rs index fabd2e5..780c62e 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);