mockersf / serde_dynamodb

Talk with dynamodb using your existing structs thanks to serde

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Best Effort For "Any"

jatsrt opened this issue · comments

Is it worth doing a best effort for deserialize_any. In somewhat complex and deep structs, I find that any is getting defaulted to quite a bit. Most of the dynamo types have a natural fall back. Example:

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value>
    where V: serde::de::Visitor<'de> {
        let f = self
            .read
            .get_attribute_value(&self.current_field)
            .ok_or_else(|| Error {
                message: format!("missing for field {:?}", &self.current_field),
            })?
            .clone();
        if f.l.is_some() || f.ns.is_some() || f.ss.is_some() {
            self.deserialize_seq(visitor)
        } else if f.n.is_some() {
            self.deserialize_f64(visitor)
        } else if f.s.is_some() {
            self.deserialize_str(visitor)
        } else if f.m.is_some() {
            self.deserialize_map(visitor)
        } else {
            log::info!("Field: {:?}", &self.current_field);
            unimplemented!()
        }
    }

Also to note, not doing these as a PR, as I am not completely clear on the full intentions of the library, but thought I might put this out there and see what you think.

done in v0.4.0