ruma_events/receipt/
receipt_thread_serde.rs

1use serde::{Deserialize, Deserializer, Serialize, Serializer};
2
3use super::ReceiptThread;
4
5impl Serialize for ReceiptThread {
6    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
7    where
8        S: Serializer,
9    {
10        self.as_str().serialize(serializer)
11    }
12}
13
14impl<'de> Deserialize<'de> for ReceiptThread {
15    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
16    where
17        D: Deserializer<'de>,
18    {
19        let s = ruma_common::serde::deserialize_cow_str(deserializer)?;
20        Self::try_from(Some(s)).map_err(serde::de::Error::custom)
21    }
22}