feat(tvix/serde): implement enum deserialisation
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>
This commit is contained in:
parent
0e88eb83ef
commit
34be6466d4
4 changed files with 189 additions and 7 deletions
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue