Skip to content

Commit

Permalink
Improve naming and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
leftmostcat committed Apr 17, 2024
1 parent 5f65e7d commit c1dbd49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/types/soap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -77,7 +77,7 @@ where
return Err(Error::RequestFault(Box::new(fault)));
}

let envelope: DummyEnvelope<B> = quick_xml::de::from_reader(document)?;
let envelope: DeserializeEnvelope<B> = quick_xml::de::from_reader(document)?;

Ok(Envelope {
body: envelope.body,
Expand Down
12 changes: 9 additions & 3 deletions src/types/soap/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>
pub(super) struct DeserializeEnvelope<T>
where
T: OperationResponse,
{
Expand Down Expand Up @@ -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
)));
}
Expand All @@ -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
)))
}
Expand Down

0 comments on commit c1dbd49

Please sign in to comment.