federation-api: Move Visitor declaration into deserialize function
This commit is contained in:
parent
212153ea5f
commit
87e821094c
@ -7,6 +7,12 @@ use serde::{
|
|||||||
Deserialize, Serialize,
|
Deserialize, Serialize,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
struct WrappedError {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
error: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
pub fn serialize<S>(
|
pub fn serialize<S>(
|
||||||
response: &BTreeMap<EventId, Result<(), String>>,
|
response: &BTreeMap<EventId, Result<(), String>>,
|
||||||
serializer: S,
|
serializer: S,
|
||||||
@ -33,18 +39,9 @@ pub fn deserialize<'de, D>(
|
|||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
deserializer.deserialize_map(PduProcessResponseVisitor)
|
struct PduProcessResponseVisitor;
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
impl<'de> Visitor<'de> for PduProcessResponseVisitor {
|
||||||
struct WrappedError {
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
error: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PduProcessResponseVisitor;
|
|
||||||
|
|
||||||
impl<'de> Visitor<'de> for PduProcessResponseVisitor {
|
|
||||||
type Value = BTreeMap<EventId, Result<(), String>>;
|
type Value = BTreeMap<EventId, Result<(), String>>;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
@ -66,6 +63,9 @@ impl<'de> Visitor<'de> for PduProcessResponseVisitor {
|
|||||||
}
|
}
|
||||||
Ok(map)
|
Ok(map)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deserializer.deserialize_map(PduProcessResponseVisitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user