Hi! Very newbee question!
Is there a way to clone the deserialize
param to use it to check if it's already an ObjectId if this is not a string?
fn deserialize_objectid<'de, D>(
deserializer: D,
) -> Result<ObjectId, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
ObjectId::with_string(&*s).map_err(|_| {
serde::de::Error::invalid_type(serde::de::Unexpected::Str(&*s), &"Should be a valid ObjectId")
})
}