@@ -49,7 +49,7 @@ pub struct ItemShape {
49
49
}
50
50
51
51
/// An identifier for a property on an Exchange entity.
52
- #[ derive( Debug , XmlSerialize ) ]
52
+ #[ derive( Debug , Deserialize , XmlSerialize ) ]
53
53
#[ xml_struct( variant_ns_prefix = "t" ) ]
54
54
pub enum PathToElement {
55
55
/// An identifier for an extended MAPI property.
@@ -162,7 +162,7 @@ pub struct ExtendedFieldURI {
162
162
/// A well-known MAPI property set identifier.
163
163
///
164
164
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/extendedfielduri#distinguishedpropertysetid-attribute>
165
- #[ derive( Clone , Copy , Debug , XmlSerialize ) ]
165
+ #[ derive( Clone , Copy , Debug , Deserialize , XmlSerialize ) ]
166
166
#[ xml_struct( text) ]
167
167
pub enum DistinguishedPropertySet {
168
168
Address ,
@@ -177,10 +177,32 @@ pub enum DistinguishedPropertySet {
177
177
UnifiedMessaging ,
178
178
}
179
179
180
+ /// Identifies the type of conflict resolution to try during an update. The default value is AutoResolve.
181
+ ///
182
+ /// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/updateitem#conflictresolution-attribute>
183
+ #[ derive( Clone , Copy , Debug , Deserialize , XmlSerialize ) ]
184
+ #[ xml_struct( text) ]
185
+ pub enum ConflictResolution {
186
+ NeverOverwrite ,
187
+ AutoResolve ,
188
+ AlwaysOverwrite ,
189
+ }
190
+
191
+ /// The action an Exchange server will take upon creating or updating a `Message` item.
192
+ ///
193
+ /// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/createitem#messagedisposition-attribute>
194
+ #[ derive( Clone , Copy , Debug , Deserialize , XmlSerialize ) ]
195
+ #[ xml_struct( text) ]
196
+ pub enum MessageDisposition {
197
+ SaveOnly ,
198
+ SendOnly ,
199
+ SendAndSaveCopy ,
200
+ }
201
+
180
202
/// The type of the value of a MAPI property.
181
203
///
182
204
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/extendedfielduri#propertytype-attribute>
183
- #[ derive( Clone , Copy , Debug , XmlSerialize ) ]
205
+ #[ derive( Clone , Copy , Debug , Deserialize , XmlSerialize ) ]
184
206
#[ xml_struct( text) ]
185
207
pub enum PropertyType {
186
208
ApplicationTime ,
@@ -297,7 +319,7 @@ pub struct FolderId {
297
319
///
298
320
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/itemids>
299
321
// N.B.: Commented-out variants are not yet implemented.
300
- #[ derive( Debug , XmlSerialize ) ]
322
+ #[ derive( Debug , Deserialize , XmlSerialize ) ]
301
323
#[ xml_struct( variant_ns_prefix = "t" ) ]
302
324
pub enum BaseItemId {
303
325
/// An identifier for a standard Exchange item.
@@ -458,7 +480,7 @@ impl XmlSerialize for DateTime {
458
480
/// An email message.
459
481
///
460
482
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/message-ex15websvcsotherref>
461
- #[ derive( Debug , Deserialize ) ]
483
+ #[ derive( Debug , Deserialize , XmlSerialize ) ]
462
484
#[ serde( rename_all = "PascalCase" ) ]
463
485
pub struct Message {
464
486
/// The MIME content of the item.
@@ -528,6 +550,65 @@ pub struct Message {
528
550
pub conversation_id : Option < ItemId > ,
529
551
}
530
552
553
+
554
+ // Add this Default implementation
555
+ impl Default for Message {
556
+ fn default ( ) -> Self {
557
+ Self {
558
+ is_read : None ,
559
+ mime_content : None ,
560
+ item_id : ItemId {
561
+ id : "" . to_string ( ) ,
562
+ change_key : None ,
563
+ } ,
564
+ parent_folder_id : None ,
565
+ item_class : None ,
566
+ subject : None ,
567
+ sensitivity : None ,
568
+ body : None ,
569
+ attachments : None ,
570
+ date_time_received : None ,
571
+ size : None ,
572
+ categories : None ,
573
+ importance : None ,
574
+ in_reply_to : None ,
575
+ is_submitted : None ,
576
+ is_draft : None ,
577
+ is_from_me : None ,
578
+ is_resend : None ,
579
+ is_unmodified : None ,
580
+ internet_message_headers : None ,
581
+ date_time_sent : None ,
582
+ date_time_created : None ,
583
+ reminder_due_by : None ,
584
+ reminder_is_set : None ,
585
+ reminder_minutes_before_start : None ,
586
+ display_cc : None ,
587
+ display_to : None ,
588
+ has_attachments : None ,
589
+ culture : None ,
590
+ sender : None ,
591
+ to_recipients : None ,
592
+ cc_recipients : None ,
593
+ bcc_recipients : None ,
594
+ is_read_receipt_requested : None ,
595
+ is_delivery_receipt_requested : None ,
596
+ conversation_index : None ,
597
+ conversation_topic : None ,
598
+ from : None ,
599
+ internet_message_id : None ,
600
+ is_response_requested : None ,
601
+ reply_to : None ,
602
+ received_by : None ,
603
+ received_representing : None ,
604
+ last_modified_name : None ,
605
+ last_modified_time : None ,
606
+ is_associated : None ,
607
+ conversation_id : None ,
608
+ }
609
+ }
610
+ }
611
+
531
612
/// A list of attachments.
532
613
///
533
614
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/attachments-ex15websvcsotherref>
@@ -917,6 +998,43 @@ pub struct MessageXml {
917
998
pub back_off_milliseconds : Option < usize > ,
918
999
}
919
1000
1001
+ /// Represents a change to an individual item, including the item ID and updates.
1002
+ #[ derive( Debug , Deserialize , XmlSerialize ) ]
1003
+ pub struct ItemChange {
1004
+ #[ serde( rename = "t:ItemId" ) ]
1005
+ pub item_id : BaseItemId , // Represents the <t:ItemId> element with Id and ChangeKey.
1006
+
1007
+ #[ serde( rename = "t:Updates" ) ]
1008
+ pub updates : Updates , // Represents the <t:Updates> element containing the changes.
1009
+ }
1010
+
1011
+ /// Represents a list of item changes without an explicit container tag.
1012
+ #[ derive( Debug , Deserialize , XmlSerialize ) ]
1013
+ pub struct ItemChanges {
1014
+ #[ serde( rename = "t:ItemChange" ) ]
1015
+ pub item_changes : Vec < ItemChange > ,
1016
+ }
1017
+
1018
+ /// Struct representing the field update operation.
1019
+ ///
1020
+ /// This struct contains details of the field that needs to be updated (in this case, marking a message as read/unread).
1021
+ #[ derive( Debug , Deserialize , XmlSerialize ) ]
1022
+ pub struct SetItemField {
1023
+ #[ serde( rename = "t:FieldURI" ) ]
1024
+ pub field_uri : PathToElement , // Reference to the field being updated.
1025
+ #[ serde( rename = "t:Message" ) ]
1026
+ pub message : Message , // The new value for the specified field.
1027
+ }
1028
+
1029
+ /// Struct representing updates to be applied to an item.
1030
+ ///
1031
+ /// This struct is used to create an UpdateItem request to mark emails as read or unread.
1032
+ #[ derive( Debug , Deserialize , XmlSerialize ) ]
1033
+ pub struct Updates {
1034
+ #[ serde( rename = "t:SetItemField" ) ]
1035
+ pub set_item_field : SetItemField ,
1036
+ }
1037
+
920
1038
#[ cfg( test) ]
921
1039
mod tests {
922
1040
use quick_xml:: Writer ;
0 commit comments