diff options
author | Nadrieril Feneanar | 2019-08-03 22:21:40 +0200 |
---|---|---|
committer | GitHub | 2019-08-03 22:21:40 +0200 |
commit | ded09933a6783d1124b6c22ff0818fb525c3141d (patch) | |
tree | 5a4839e450b7fd09429742033c5b9732e453e2d1 /dhall/src/phase/binary.rs | |
parent | 30bc224b524031fbf64057516961831890bb749c (diff) | |
parent | 016893b00fcd916099e0349affc124fdd6275c67 (diff) |
Merge pull request #93 from Nadrieril/catchup-spec
Do some catch up on the spec
Diffstat (limited to '')
-rw-r--r-- | dhall/src/phase/binary.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/dhall/src/phase/binary.rs b/dhall/src/phase/binary.rs index 96eaa6c..1812131 100644 --- a/dhall/src/phase/binary.rs +++ b/dhall/src/phase/binary.rs @@ -196,17 +196,15 @@ fn cbor_value_to_dhall( }; let hash = match hash { Null => None, - Array(vec) => match vec.as_slice() { - [String(protocol), String(hash)] => Some(Hash { - protocol: protocol.clone(), - hash: hash.clone(), - }), - _ => Err(DecodeError::WrongFormatError( - "import/hash".to_owned(), - ))?, + Bytes(bytes) => match bytes.as_slice() { + [18, 32, rest..] => Some(Hash::SHA256(rest.to_vec())), + _ => Err(DecodeError::WrongFormatError(format!( + "import/hash/unknown_multihash: {:?}", + bytes + )))?, }, _ => Err(DecodeError::WrongFormatError( - "import/hash".to_owned(), + "import/hash/should_be_bytes".to_owned(), ))?, }; let mut rest = rest.iter(); @@ -518,7 +516,7 @@ fn serialize_import<S>(ser: S, import: &Import) -> Result<S::Ok, S::Error> where S: serde::ser::Serializer, { - use cbor::Value::{Array, Null, String, U64}; + use cbor::Value::{Bytes, Null, U64}; use serde::ser::SerializeSeq; let count = 4 + match &import.location_hashed.location { @@ -533,8 +531,10 @@ where let hash = match &import.location_hashed.hash { None => Null, - Some(h) => { - Array(vec![String(h.protocol.clone()), String(h.hash.clone())]) + Some(Hash::SHA256(h)) => { + let mut bytes = vec![18, 32]; + bytes.extend_from_slice(h); + Bytes(bytes) } }; ser_seq.serialize_element(&hash)?; |