From 3ee2ee2046b38d03b9b7c85b128ab644cb410c06 Mon Sep 17 00:00:00 2001 From: Sean Burke Date: Mon, 2 Dec 2024 13:39:52 -0800 Subject: [PATCH 1/2] Correct Folder namespaces and CreateFolderResponse structure --- src/types/common.rs | 77 ++++++++++++++++++++++++++++++++++++++ src/types/create_folder.rs | 6 +-- src/types/get_folder.rs | 11 +----- 3 files changed, 81 insertions(+), 13 deletions(-) diff --git a/src/types/common.rs b/src/types/common.rs index 186f880..26f0b02 100644 --- a/src/types/common.rs +++ b/src/types/common.rs @@ -804,18 +804,32 @@ pub struct ItemId { /// The representation of a folder in an EWS operation. #[derive(Clone, Debug, Deserialize, XmlSerialize)] +#[xml_struct(variant_ns_prefix = "t")] pub enum Folder { /// A calendar folder in a mailbox. /// /// See #[serde(rename_all = "PascalCase")] CalendarFolder { + #[xml_struct(ns_prefix = "t")] folder_id: Option, + + #[xml_struct(ns_prefix = "t")] parent_folder_id: Option, + + #[xml_struct(ns_prefix = "t")] folder_class: Option, + + #[xml_struct(ns_prefix = "t")] display_name: Option, + + #[xml_struct(ns_prefix = "t")] total_count: Option, + + #[xml_struct(ns_prefix = "t")] child_folder_count: Option, + + #[xml_struct(ns_prefix = "t")] extended_property: Option>, }, @@ -824,12 +838,25 @@ pub enum Folder { /// See #[serde(rename_all = "PascalCase")] ContactsFolder { + #[xml_struct(ns_prefix = "t")] folder_id: Option, + + #[xml_struct(ns_prefix = "t")] parent_folder_id: Option, + + #[xml_struct(ns_prefix = "t")] folder_class: Option, + + #[xml_struct(ns_prefix = "t")] display_name: Option, + + #[xml_struct(ns_prefix = "t")] total_count: Option, + + #[xml_struct(ns_prefix = "t")] child_folder_count: Option, + + #[xml_struct(ns_prefix = "t")] extended_property: Option>, }, @@ -838,13 +865,28 @@ pub enum Folder { /// See #[serde(rename_all = "PascalCase")] Folder { + #[xml_struct(ns_prefix = "t")] folder_id: Option, + + #[xml_struct(ns_prefix = "t")] parent_folder_id: Option, + + #[xml_struct(ns_prefix = "t")] folder_class: Option, + + #[xml_struct(ns_prefix = "t")] display_name: Option, + + #[xml_struct(ns_prefix = "t")] total_count: Option, + + #[xml_struct(ns_prefix = "t")] child_folder_count: Option, + + #[xml_struct(ns_prefix = "t")] extended_property: Option>, + + #[xml_struct(ns_prefix = "t")] unread_count: Option, }, @@ -853,12 +895,25 @@ pub enum Folder { /// See #[serde(rename_all = "PascalCase")] SearchFolder { + #[xml_struct(ns_prefix = "t")] folder_id: Option, + + #[xml_struct(ns_prefix = "t")] parent_folder_id: Option, + + #[xml_struct(ns_prefix = "t")] folder_class: Option, + + #[xml_struct(ns_prefix = "t")] display_name: Option, + + #[xml_struct(ns_prefix = "t")] total_count: Option, + + #[xml_struct(ns_prefix = "t")] child_folder_count: Option, + + #[xml_struct(ns_prefix = "t")] extended_property: Option>, }, @@ -867,12 +922,25 @@ pub enum Folder { /// See #[serde(rename_all = "PascalCase")] TasksFolder { + #[xml_struct(ns_prefix = "t")] folder_id: Option, + + #[xml_struct(ns_prefix = "t")] parent_folder_id: Option, + + #[xml_struct(ns_prefix = "t")] folder_class: Option, + + #[xml_struct(ns_prefix = "t")] display_name: Option, + + #[xml_struct(ns_prefix = "t")] total_count: Option, + + #[xml_struct(ns_prefix = "t")] child_folder_count: Option, + + #[xml_struct(ns_prefix = "t")] extended_property: Option>, }, } @@ -884,6 +952,15 @@ pub struct Items { pub inner: Vec, } +/// A collection of information on Exchange folders. +/// +/// See +#[derive(Clone, Debug, Deserialize)] +pub struct Folders { + #[serde(rename = "$value", default)] + pub inner: Vec, +} + /// An item which may appear as the result of a request to read or modify an /// Exchange item. /// diff --git a/src/types/create_folder.rs b/src/types/create_folder.rs index 5dec79b..239aad3 100644 --- a/src/types/create_folder.rs +++ b/src/types/create_folder.rs @@ -6,8 +6,8 @@ use serde::Deserialize; use xml_struct::XmlSerialize; use crate::{ - types::sealed::EnvelopeBodyContents, BaseFolderId, Folder, Operation, OperationResponse, - ResponseClass, ResponseCode, MESSAGES_NS_URI, + types::sealed::EnvelopeBodyContents, BaseFolderId, Folder, Folders, Operation, + OperationResponse, ResponseClass, ResponseCode, MESSAGES_NS_URI, }; /// A request to create a new folder. @@ -65,5 +65,5 @@ pub struct CreateFolderResponseMessage { pub message_text: Option, - pub folders: Vec, + pub folders: Folders, } diff --git a/src/types/get_folder.rs b/src/types/get_folder.rs index 85c97a4..d21a2a5 100644 --- a/src/types/get_folder.rs +++ b/src/types/get_folder.rs @@ -6,7 +6,7 @@ use serde::Deserialize; use xml_struct::XmlSerialize; use crate::{ - types::sealed::EnvelopeBodyContents, BaseFolderId, Folder, FolderShape, Operation, + types::sealed::EnvelopeBodyContents, BaseFolderId, FolderShape, Folders, Operation, OperationResponse, ResponseClass, ResponseCode, MESSAGES_NS_URI, }; @@ -78,12 +78,3 @@ pub struct GetFolderResponseMessage { /// A collection of the retrieved folders. pub folders: Folders, } - -/// A collection of information on Exchange folders. -/// -/// See -#[derive(Clone, Debug, Deserialize)] -pub struct Folders { - #[serde(rename = "$value")] - pub inner: Vec, -} From 0cf8540b9c8fccf3e154de2e44eb7fba9b07e723 Mon Sep 17 00:00:00 2001 From: Sean Burke Date: Mon, 2 Dec 2024 13:45:54 -0800 Subject: [PATCH 2/2] Make clippy happy --- src/types/soap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/soap.rs b/src/types/soap.rs index 9b322f6..0fda01c 100644 --- a/src/types/soap.rs +++ b/src/types/soap.rs @@ -345,7 +345,7 @@ impl<'content> ScopedReader<'content> { // send all responses as UTF-8. We'll encounter bigger problems // elsewhere if we run into a non-UTF-8 document, most notably that we // currently don't enable the `encoding` feature for quick-xml. - return Ok(Self::from_bytes(content)); + Ok(Self::from_bytes(content)) } /// Gets a string representation of the contents of the current reader.