#[derive(JominiDeserialize)]
struct MyData {
known_field: u32,
#[jomini(collect)]
other: HashMap<String, u32>
}
such that when given the input:
"a" and "b" will be in the "other" field.
The field being collected into should support custom deserialization:
struct MyData {
known_field: u32,
#[jomini(collect, deserialize_with = "deserialize_vec_pair")]
other: Vec<(String, u32)>,
}
The key / identifier in the collected field can be a non-string.
struct MyData {
known_field: u32,
#[jomini(collect, deserialize_with = "deserialize_vec_pair")]
other: Vec<(char, u32)>,
}
One requirement is allowing the downstream developer the ability to collect only fields that match a certain pattern. For instance,
known_field=10
a=20
b=20
something_else=20
In these cases, the caller sees "something_else" and can elect to skip / ignore the value such that it is not collected into the container. Ideally we wouldn't need to special case the container types.
There may not be a way to avoid string allocations to hold the unknown fields, but as long as this is only limited to structs with the collect attribute, the blast radius of this performance impact should be tolerable.
Text tape and streaming deserializers should support the collect attribute
such that when given the input:
"a" and "b" will be in the "other" field.
The field being collected into should support custom deserialization:
The key / identifier in the collected field can be a non-string.
One requirement is allowing the downstream developer the ability to collect only fields that match a certain pattern. For instance,
In these cases, the caller sees "something_else" and can elect to skip / ignore the value such that it is not collected into the container. Ideally we wouldn't need to special case the container types.
There may not be a way to avoid string allocations to hold the unknown fields, but as long as this is only limited to structs with the
collectattribute, the blast radius of this performance impact should be tolerable.Text tape and streaming deserializers should support the collect attribute