Is there any way to just tell serde to ignore errors when deserializing? E.g. for something like
/// The main data structure for deserializing with serde.
#[derive(Deserialize)]
struct SerdeDataSourceHelper {
title: Option<String>,
base_url: Option<String>, // ???
projects: Option<BTreeMap<String, BTreeMap<Url, BTreeMap<String, SerdeForkOptions>>>>,
repo_list_srcs: Option<Vec<SerdeRepoList>>,
project: Option<BTreeMap<String, SerdeProjectOptions>>,
}
/// The options for a given fork.
#[derive(Deserialize)]
struct SerdeForkOptions {
active: bool,
federate: bool,
}
/// A repo list.
#[derive(Deserialize)]
struct SerdeRepoList {
url: Url,
active: bool,
allow_negative_entries: bool,
}
/// The options for a given project (all forks).
#[derive(Deserialize)]
struct SerdeProjectOptions {
active: bool,
}
is there any way to tell serde to just... ignore stuff that doesn't match the expectation? So if someone shoved a list where a deeper level of the BTreeMap was expected it'd just ignore that list entirely, etc etc?
Maybe something with using an untagged wrapper enum...? Surely there's a better way of doing this? .-.
Say, why's there no Result<T, ()> serialization, equivalent to Option<T> but discards deserialization errors? Seems like it could be useful for error management.
Using Result<T, ()> for this would be incompatible with serde's existing blanket impl. Defining a meaningful, specific wrapper type seems better in pretty much every way.