diff --git a/src/types/soap.rs b/src/types/soap.rs index 51e49e0..ed6e2fe 100644 --- a/src/types/soap.rs +++ b/src/types/soap.rs @@ -12,7 +12,7 @@ use crate::{ }; mod de; -use self::de::DummyEnvelope; +use self::de::DeserializeEnvelope; /// A SOAP envelope containing the body of an EWS operation or response. /// @@ -77,7 +77,7 @@ where return Err(Error::RequestFault(Box::new(fault))); } - let envelope: DummyEnvelope = quick_xml::de::from_reader(document)?; + let envelope: DeserializeEnvelope = quick_xml::de::from_reader(document)?; Ok(Envelope { body: envelope.body, diff --git a/src/types/soap/de.rs b/src/types/soap/de.rs index 00fe5a0..8ef577c 100644 --- a/src/types/soap/de.rs +++ b/src/types/soap/de.rs @@ -8,9 +8,15 @@ use serde::{de::Visitor, Deserialize, Deserializer}; use crate::OperationResponse; +/// A helper for deserialization of SOAP envelopes. +/// +/// This struct is declared separately from the more general [`Envelope`] type +/// so that the latter can be used with types that are write-only. +/// +/// [`Envelope`]: super::Envelope #[derive(Deserialize)] #[serde(rename_all = "PascalCase")] -pub(super) struct DummyEnvelope +pub(super) struct DeserializeEnvelope where T: OperationResponse, { @@ -50,7 +56,7 @@ where let expected = T::name(); if name.as_str() != expected { return Err(serde::de::Error::custom(format_args!( - "unknown field `{}`, expected {}", + "unknown element `{}`, expected {}", name, expected ))); } @@ -64,7 +70,7 @@ where // The response body contained more than one element, // which violates our expectations. Err(serde::de::Error::custom(format_args!( - "unexpected field `{}`", + "unexpected element `{}`", name ))) }