Module serde_taml::de::type_overrides [−][src]
Expand description
TAML type overrides affect only the expected TAML representation of a value,
but not how the super::Deserializer
interacts with Serde
(beyond delayed panics on encountering incompatibilities).
Warning:
I had to use a (thread-local) side channel here. It should be well-behaved with any
de::Deserialize
implementation that Serde generated, but there may be issues if you jump between two deserializers.A proper fix is planned, but can only be implemented on stable once trait specialisation lands.
Serde/TAML compatibility table
deserialize_… | TAML | ||||||
---|---|---|---|---|---|---|---|
data literal | decimal | enum variant | integer | list | string | struct | |
any | (restricting to one default cell below, in a row marked with "(any)") | ||||||
bool (any) |
true , false |
1 , 0 |
"true" , "false" |
||||
u8, i8, u16, i16, u32, i32, u64, i64, u128, i128 (any, in that order) |
any integer | ||||||
f32, f64 (any, always as f64) |
any decimal | any integer | |||||
char | single-codepoint identifier only | single digit | single-codepoint | ||||
str, string (any) |
literal without trailing zeroes¹ | identifier only | full literal | unquoted and unescaped | |||
bytes, bytes_buf (any) |
encoded | identifier only, in UTF-8 | unquoted and unescaped in UTF-8 | ||||
option | (transparent) | ||||||
unit | () |
no fields only | |||||
unit_struct | () |
no fields only | |||||
newtype_struct | (transparent) | ||||||
seq (any) |
any list | ||||||
tuple, tuple_struct | exact length only | ||||||
map (any) |
any struct | ||||||
struct | exact fields only² | ||||||
enum (any, unless bool-compatible) |
any enum variant³ | ||||||
identifier | literal without trailing zeroes¹ | identifier only | full literal | unquoted and unescaped | |||
ignored_any | (restricting to TAML value type; data literals are not validated) |
¹ Except for one directly following the decimal point, of course, since that is required by TAML.
² A field called taml::extra_fields
is treated specially, absorbing any otherwise unrecognised fields as nested TAML struct.
³ Use the "serde-object-assist"
feature to predict enum variants, if necessary.
Functions
Overrides TAML value type restrictions to expect a data literal.
Overrides TAML value type restrictions to expect a decimal.
Overrides TAML value type restrictions to expect an enum variant.
Overrides TAML value type restrictions to expect an integer.
Overrides TAML value type restrictions to expect a list.
Overrides TAML value type restrictions to expect a string.
Overrides TAML value type restrictions to expect a struct.