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

Defaults are highlighted in green and prefixed with "(default)". Unsupported combinations are shown as empty space.

The leftmost column denotes methods in Serde's de::Deserializer trait while the rest of the table shows TAML value types and their validity per Serde method.

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)
(default) true, false 1, 0 "true", "false"
u8, i8, u16, i16, u32, i32, u64, i64, u128, i128
(any, in that order)
(default) any integer
f32, f64
(any, always as f64)
(default) any decimal any integer
char single-codepoint identifier only single digit (default)single-codepoint
str, string
(any)
literal without trailing zeroes¹ identifier only full literal (default)unquoted and unescaped
bytes, bytes_buf
(any)
(default)encoded identifier only, in UTF-8 unquoted and unescaped in UTF-8
option (transparent)
unit (default) () no fields only
unit_struct () (default)no fields only
newtype_struct (transparent)
seq
(any)
(default)any list
tuple, tuple_struct (default)exact length only
map
(any)
(default)any struct
struct (default)exact fields only²
enum
(any, unless bool-compatible)
(default)any enum variant³
identifier literal without trailing zeroes¹ (default)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.