diff options
Diffstat (limited to 'dhall/src/syntax/binary')
-rw-r--r-- | dhall/src/syntax/binary/decode.rs | 21 | ||||
-rw-r--r-- | dhall/src/syntax/binary/encode.rs | 4 |
2 files changed, 25 insertions, 0 deletions
diff --git a/dhall/src/syntax/binary/decode.rs b/dhall/src/syntax/binary/decode.rs index 195bd0a..d360949 100644 --- a/dhall/src/syntax/binary/decode.rs +++ b/dhall/src/syntax/binary/decode.rs @@ -434,6 +434,27 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result<DecodedExpr, DecodeError> { let x = cbor_value_to_dhall(&x)?; EmptyListLit(x) } + [U64(29), x, labels, y] => { + let x = cbor_value_to_dhall(&x)?; + let y = cbor_value_to_dhall(&y)?; + let labels = match labels { + Array(labels) => labels + .iter() + .map(|s| match s { + String(s) => Ok(Label::from(s.as_str())), + _ => Err(DecodeError::WrongFormatError( + "with".to_owned(), + )), + }) + .collect::<Result<_, _>>()?, + _ => { + return Err(DecodeError::WrongFormatError( + "with".to_owned(), + )) + } + }; + Op(With(x, labels, y)) + } _ => { return Err(DecodeError::WrongFormatError(format!( "{:?}", diff --git a/dhall/src/syntax/binary/encode.rs b/dhall/src/syntax/binary/encode.rs index b6bbabe..33c7fa5 100644 --- a/dhall/src/syntax/binary/encode.rs +++ b/dhall/src/syntax/binary/encode.rs @@ -171,6 +171,10 @@ where Op(Completion(x, y)) => { ser_seq!(ser; tag(3), tag(13), expr(x), expr(y)) } + Op(With(x, ls, y)) => { + let ls: Vec<_> = ls.iter().map(label).collect(); + ser_seq!(ser; tag(29), expr(x), ls, expr(y)) + } Import(import) => serialize_import(ser, import), } } |