diff options
author | Vincent Ambo <mail@tazj.in> | 2023-01-02T10·39+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2023-01-04T17·21+0000 |
commit | 34be6466d4a5da7dd3ad55ce80c951f21e45520c (patch) | |
tree | 28456ec15c4a2c6cae8eab74ebb5434be599b8e0 /tvix/serde/src/error.rs | |
parent | 0e88eb83efb194427329ccffd3b48671e1d72107 (diff) |
feat(tvix/serde): implement enum deserialisation r/5585
Implements externally tagged enum deserialisation. Other serialisation methods are handled by serde internally using the existing methods. See the tests for examples. Change-Id: Ic4a9da3b5a32ddbb5918b1512e70c3ac5ce64f04 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7721 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/serde/src/error.rs')
-rw-r--r-- | tvix/serde/src/error.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tvix/serde/src/error.rs b/tvix/serde/src/error.rs index fb83105cd210..f206b830e95f 100644 --- a/tvix/serde/src/error.rs +++ b/tvix/serde/src/error.rs @@ -31,6 +31,12 @@ pub enum Error { errors: Vec<tvix_eval::Error>, source: tvix_eval::SourceCode, }, + + /// Could not determine an externally tagged enum representation. + AmbiguousEnum, + + /// Attempted to provide content to a unit enum. + UnitEnumContent, } impl Display for Error { @@ -69,6 +75,10 @@ impl Display for Error { Error::IntegerConversion { got, need } => { write!(f, "i64({}) does not fit in a {}", got, need) } + + Error::AmbiguousEnum => write!(f, "could not determine enum variant: ambiguous keys"), + + Error::UnitEnumContent => write!(f, "provided content for unit enum variant"), } } } |