Skip to content

Commit

Permalink
Moved extended_property and struct to common.rs (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobypilling authored Nov 1, 2024
1 parent cd5d38b commit ac08a7b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
24 changes: 20 additions & 4 deletions src/types/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub enum PathToElement {
// which follows the same structure. However, xml-struct doesn't currently
// support using a nested structure to define an element's attributes, see
// https://github.com/thunderbird/xml-struct-rs/issues/9
#[derive(Clone, Debug, XmlSerialize)]
#[derive(Clone, Debug, Deserialize, XmlSerialize)]
pub struct ExtendedFieldURI {
/// A well-known identifier for a property set.
#[xml_struct(attribute)]
Expand Down Expand Up @@ -162,7 +162,7 @@ pub struct ExtendedFieldURI {
/// A well-known MAPI property set identifier.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/extendedfielduri#distinguishedpropertysetid-attribute>
#[derive(Clone, Copy, Debug, XmlSerialize)]
#[derive(Clone, Copy, Debug, Deserialize, XmlSerialize)]
#[xml_struct(text)]
pub enum DistinguishedPropertySet {
Address,
Expand Down Expand Up @@ -192,7 +192,7 @@ pub enum MessageDisposition {
/// The type of the value of a MAPI property.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/extendedfielduri#propertytype-attribute>
#[derive(Clone, Copy, Debug, XmlSerialize)]
#[derive(Clone, Copy, Debug, Deserialize, XmlSerialize)]
#[xml_struct(text)]
pub enum PropertyType {
ApplicationTime,
Expand Down Expand Up @@ -503,6 +503,9 @@ pub struct Message {
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/categories-ex15websvcsotherref>
pub categories: Option<Vec<StringElement>>,

// Extended MAPI properties to set on the message.
pub extended_property: Option<Vec<ExtendedProperty>>,
pub importance: Option<Importance>,
pub in_reply_to: Option<String>,
pub is_submitted: Option<bool>,
Expand Down Expand Up @@ -541,6 +544,19 @@ pub struct Message {
pub conversation_id: Option<ItemId>,
}

/// An extended MAPI property to set on the message.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/extendedproperty>
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize, XmlSerialize)]
pub struct ExtendedProperty {
#[xml_struct(ns_prefix = "t")]
pub extended_field_URI: ExtendedFieldURI,

#[xml_struct(ns_prefix = "t")]
pub value: String,
}

/// A list of attachments.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/attachments-ex15websvcsotherref>
Expand Down Expand Up @@ -618,7 +634,7 @@ pub struct InternetMessageHeaders {
/// A reference to a user or address which can send or receive mail.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/mailbox>
#[derive(Clone, Debug, Deserialize, XmlSerialize, PartialEq)]
#[derive(Clone, Debug, Default, Deserialize, XmlSerialize, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct Mailbox {
/// The name of this mailbox's user.
Expand Down
17 changes: 2 additions & 15 deletions src/types/create_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use serde::Deserialize;
use xml_struct::XmlSerialize;

use crate::{
types::sealed::EnvelopeBodyContents, BaseFolderId, ExtendedFieldURI, Items, MessageDisposition,
Operation, OperationResponse, RealItem, ResponseClass, ResponseCode, MESSAGES_NS_URI,
types::sealed::EnvelopeBodyContents, BaseFolderId, Items, MessageDisposition, Operation,
OperationResponse, RealItem, ResponseClass, ResponseCode, MESSAGES_NS_URI,
};

/// A request to create (and optionally send) one or more Exchange items.
Expand Down Expand Up @@ -39,19 +39,6 @@ pub struct CreateItem {
pub items: Vec<RealItem>,
}

/// An extended MAPI property to set on the message.
///
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/extendedproperty>
#[allow(non_snake_case)]
#[derive(Clone, Debug, XmlSerialize)]
pub struct ExtendedProperty {
#[xml_struct(ns_prefix = "t")]
pub extended_field_URI: ExtendedFieldURI,

#[xml_struct(ns_prefix = "t")]
pub value: String,
}

impl Operation for CreateItem {
type Response = CreateItemResponse;
}
Expand Down

0 comments on commit ac08a7b

Please sign in to comment.