You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful to have a structure that represents every possible value we can deserialize into. Example:
// here's deserializer into a generic Valuelet value:HashMap<String, jomini::Value> = jomini::text::de::from_utf8_slice(r#" unquoted = 1234 quoted = "567" operator > 0.5 color = hsv { 0.3 0.4 0.5 } sequence = { 1 2 3 4 } map = { a = 1 b = 2 }"#.as_bytes());// and we can deserialize it into concrete type laterlet unquoted = value.get("unquoted").unwrap();assert_eq!(f32::deserialize(unquoted.clone()).unwrap(),1234.0);
This is the similar idea to existing serde_value::Value, serde_json::Value, serde_yaml::Value and others.
it should losslessly keep any value from jomini deserializer (i.e. I can deserialize tape into it)
it should implement IntoDeserializer (i.e. I can deserialize it into any concrete value)
it should be a static type (owned)
it should implement Debug
it should give user some API to inspect the value (e.g. is it a token or a sequence)
There's ValueKind in jomini right now, but it's a borrowed type, it doesn't implement Debug, and it's not public API.
There's also generic serde_value::Value, but it is not lossless (loses quotes, operators, headers, etc.). And the code above fails with it in multiple ways (e.g. loses hsv header, loses > operator, and unquoted number is transformed into string and can't be parsed within assert statement later).
Why? I want to solve #138 in more generic way (rather than adding yet another _internal_jomini_property hack) + make low level syntax more accessible in general. Plus some visual inspection of the file contents via Debug.
The text was updated successfully, but these errors were encountered:
Yeah an arbitrary lossless value would be nice. I can imagine it essentially being what ValueReader is today, except owned, which should check most everything off your list. I think it'd need to use a hack similar to _internal_jomini_property (or it can replace it) in order for the deserializer to properly handle it.
It would be useful to have a structure that represents every possible value we can deserialize into. Example:
This is the similar idea to existing
serde_value::Value
,serde_json::Value
,serde_yaml::Value
and others.There's
ValueKind
in jomini right now, but it's a borrowed type, it doesn't implement Debug, and it's not public API.There's also generic
serde_value::Value
, but it is not lossless (loses quotes, operators, headers, etc.). And the code above fails with it in multiple ways (e.g. loses hsv header, loses>
operator, and unquoted number is transformed into string and can't be parsed within assert statement later).Why? I want to solve #138 in more generic way (rather than adding yet another
_internal_jomini_property
hack) + make low level syntax more accessible in general. Plus some visual inspection of the file contents via Debug.The text was updated successfully, but these errors were encountered: