use serde::ser::{Serialize, SerializeSeq, Serializer}; use crate::Timestamp; pub struct SerializableSingleValueColumn(pub T, pub usize); impl Serialize for SerializableSingleValueColumn { fn serialize(&self, serializer: S) -> Result { let mut seq = serializer.serialize_seq(Some(self.1))?; for _ in 0..self.1 { seq.serialize_element(&self.0)?; } seq.end() } } pub struct SerializableOptionalTimestampColumn<'a>(pub &'a [Option]); impl<'a> Serialize for SerializableOptionalTimestampColumn<'a> { fn serialize(&self, serializer: S) -> Result { let mut seq = serializer.serialize_seq(Some(self.0.len()))?; for timestamp in self.0 { match timestamp { Some(timestamp) => seq.serialize_element(×tamp)?, None => seq.serialize_element(&0.0)?, } } seq.end() } }