Open holmesv3 opened 11 months ago
Sort of yes, the idea is that we may want to handle fields not being present or failing to parse properly without failing, while also not making them Option<T>
. So, this was to look into how that would play out.
Thinking using something like #[serde(skip_serializing_if=field.is_empty)]
Ideally I don't think they'd ever be empty unless it's already an optional field. The goal here is to work out Deserialize
such that if a category like collection info fails, the program won't crash. Maybe there's a warning logged and it uses a Default
value or something.
That skip serializing thing is neat, but also specific to Serialize
, which is sort of the other end of the problem.
#[serde(default)]
could then be used instead of Option<T>
, just need to derive Default
for every subclass
That could work. I though default was only used if it wasn't present, not if there was an error parsing it. If that's the case great!
using Default
might run into some sad manual work with enums, and yea we'll need to test the error catching
standard serde?