serde_firestore_value::with::timestamp

Function deserialize

Source
pub fn deserialize<'de, D>(deserializer: D) -> Result<Timestamp, D::Error>
where D: Deserializer<'de>,
Expand description

Deserialize Timestamp from timestampValue.

ยงExamples

use serde_firestore_value::google::firestore::v1::{value::ValueType, ArrayValue, MapValue, Value};
use serde_firestore_value::{from_value, with::timestamp};

#[derive(Debug, Eq, PartialEq, serde::Deserialize)]
struct S(#[serde(deserialize_with = "timestamp::deserialize")] prost_types::Timestamp);

let o = S(prost_types::Timestamp {
    seconds: 1_i64,
    nanos: 2_i32,
});
let v = Value {
    value_type: Some(ValueType::TimestampValue(prost_types::Timestamp {
        seconds: 1_i64,
        nanos: 2_i32,
    })),
};
let d = from_value::<'_, S>(&v)?;
assert_eq!(d, o);