pub fn serialize<S>(
timestamp: &Timestamp,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
Expand description
Serialize Timestamp
as timestampValue
.
ยงExamples
use serde_firestore_value::google::firestore::v1::{value::ValueType, ArrayValue, MapValue, Value};
use prost_types::Timestamp;
use serde_firestore_value::{to_value, with::timestamp};
#[derive(Debug, Eq, PartialEq, serde::Serialize)]
struct S(#[serde(serialize_with = "timestamp::serialize")] Timestamp);
let o = S(Timestamp {
seconds: 1_i64,
nanos: 2_i32,
});
let v = Value {
value_type: Some(ValueType::TimestampValue(Timestamp {
seconds: 1_i64,
nanos: 2_i32,
})),
};
let s = to_value(&o)?;
assert_eq!(s, v);