Skip to content

Commit

Permalink
Expose name() on Operation to allow for debugging (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
leftmostcat authored Nov 7, 2024
1 parent ac08a7b commit 4125100
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/types/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ mod tests {

// Ensure the first recipient correctly has a name and address.
assert_eq!(
recipients.get(0).expect("no recipient at index 0"),
recipients.first().expect("no recipient at index 0"),
&Recipient {
mailbox: Mailbox {
name: Some("Alice Test".into()),
Expand Down
8 changes: 8 additions & 0 deletions src/types/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ pub trait Operation: XmlSerialize + sealed::EnvelopeBodyContents + std::fmt::Deb
/// The structure returned by EWS in response to requests containing this
/// operation.
type Response: OperationResponse;

/// Gets the name of the operation.
///
/// This is the same as the local part of the name of the XML element used
/// to represent this option.
fn name() -> &'static str {
<Self as sealed::EnvelopeBodyContents>::name()
}
}

/// A marker trait for EWS operation responses.
Expand Down
6 changes: 4 additions & 2 deletions src/types/soap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use quick_xml::{
};

use crate::{
Error, MessageXml, Operation, OperationResponse, ResponseCode, SOAP_NS_URI, TYPES_NS_URI,
types::sealed, Error, MessageXml, Operation, OperationResponse, ResponseCode, SOAP_NS_URI,
TYPES_NS_URI,
};

mod de;
Expand Down Expand Up @@ -48,7 +49,8 @@ where
writer.write_event(Event::Start(BytesStart::new(SOAP_BODY)))?;

// Write the operation itself.
self.body.serialize_as_element(&mut writer, B::name())?;
self.body
.serialize_as_element(&mut writer, <B as sealed::EnvelopeBodyContents>::name())?;

writer.write_event(Event::End(BytesEnd::new(SOAP_BODY)))?;
writer.write_event(Event::End(BytesEnd::new(SOAP_ENVELOPE)))?;
Expand Down

0 comments on commit 4125100

Please sign in to comment.