diff --git a/src/types/get_folder.rs b/src/types/get_folder.rs index 990d654..b739b93 100644 --- a/src/types/get_folder.rs +++ b/src/types/get_folder.rs @@ -6,7 +6,8 @@ use serde::Deserialize; use xml_struct::XmlSerialize; use crate::{ - BaseFolderId, Folder, FolderShape, Operation, OperationResponse, ResponseClass, MESSAGES_NS_URI, + types::sealed::NamedStructure, BaseFolderId, Folder, FolderShape, Operation, OperationResponse, + ResponseClass, MESSAGES_NS_URI, }; /// A request to get information on one or more folders. @@ -21,7 +22,9 @@ pub struct GetFolder { impl Operation for GetFolder { type Response = GetFolderResponse; +} +impl NamedStructure for GetFolder { fn name() -> &'static str { "GetFolder" } @@ -36,7 +39,9 @@ pub struct GetFolderResponse { pub response_messages: ResponseMessages, } -impl OperationResponse for GetFolderResponse { +impl OperationResponse for GetFolderResponse {} + +impl NamedStructure for GetFolderResponse { fn name() -> &'static str { "GetFolderResponse" } diff --git a/src/types/operations.rs b/src/types/operations.rs index d538902..b967f58 100644 --- a/src/types/operations.rs +++ b/src/types/operations.rs @@ -5,12 +5,14 @@ use serde::Deserialize; use xml_struct::XmlSerialize; -pub trait Operation: XmlSerialize { +pub trait Operation: XmlSerialize + sealed::NamedStructure { type Response: OperationResponse; - - fn name() -> &'static str; } -pub trait OperationResponse: for<'de> Deserialize<'de> { - fn name() -> &'static str; +pub trait OperationResponse: for<'de> Deserialize<'de> + sealed::NamedStructure {} + +pub(super) mod sealed { + pub trait NamedStructure { + fn name() -> &'static str; + } } diff --git a/src/types/soap.rs b/src/types/soap.rs index a8c17b2..362a5f5 100644 --- a/src/types/soap.rs +++ b/src/types/soap.rs @@ -453,7 +453,7 @@ pub struct FaultDetail { mod tests { use serde::Deserialize; - use crate::{Error, OperationResponse}; + use crate::{types::sealed::NamedStructure, Error, OperationResponse}; use super::Envelope; @@ -467,7 +467,9 @@ mod tests { _other_field: (), } - impl OperationResponse for SomeStruct { + impl OperationResponse for SomeStruct {} + + impl NamedStructure for SomeStruct { fn name() -> &'static str { "Foo" } @@ -492,7 +494,9 @@ mod tests { #[derive(Debug, Deserialize)] struct Foo; - impl OperationResponse for Foo { + impl OperationResponse for Foo {} + + impl NamedStructure for Foo { fn name() -> &'static str { "Foo" } @@ -543,7 +547,9 @@ mod tests { #[derive(Debug, Deserialize)] struct Foo; - impl OperationResponse for Foo { + impl OperationResponse for Foo {} + + impl NamedStructure for Foo { fn name() -> &'static str { "Foo" } diff --git a/src/types/sync_folder_hierarchy.rs b/src/types/sync_folder_hierarchy.rs index 722e8d2..39ec3b0 100644 --- a/src/types/sync_folder_hierarchy.rs +++ b/src/types/sync_folder_hierarchy.rs @@ -6,8 +6,8 @@ use serde::Deserialize; use xml_struct::XmlSerialize; use crate::{ - BaseFolderId, Folder, FolderId, FolderShape, Operation, OperationResponse, ResponseClass, - MESSAGES_NS_URI, + types::sealed::NamedStructure, BaseFolderId, Folder, FolderId, FolderShape, Operation, + OperationResponse, ResponseClass, MESSAGES_NS_URI, }; /// The request for update regarding the folder hierarchy in a mailbox. @@ -23,7 +23,9 @@ pub struct SyncFolderHierarchy { impl Operation for SyncFolderHierarchy { type Response = SyncFolderHierarchyResponse; +} +impl NamedStructure for SyncFolderHierarchy { fn name() -> &'static str { "SyncFolderHierarchy" } @@ -38,7 +40,9 @@ pub struct SyncFolderHierarchyResponse { pub response_messages: ResponseMessages, } -impl OperationResponse for SyncFolderHierarchyResponse { +impl OperationResponse for SyncFolderHierarchyResponse {} + +impl NamedStructure for SyncFolderHierarchyResponse { fn name() -> &'static str { "SyncFolderHierarchyResponse" }