-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created UpdateItem and added necessary trait implementations #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brendan has covered most of the things I would, but there are a few other things I'm bringing up here. I use Conventional Comments as a guideline for what's blocking and non-blocking; as such, todo
comments will need to be addressed before approval, and I generally expect question
comments to be answered as well.
As regards documentation, we should definitely remove the copy-pasted documentation before merging. I'll leave it up to you whether to rewrite it or leave it off for now, as a documentation pass is needed for several areas as it is.
416442d
to
188d3da
Compare
…w as Option<MessageDisposition>) and add Clone for all types
cb30763
to
475bd39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm asking for quite a few changes here and a lot of them are about style and convention in documentation or ordering of files for consistency. Additionally, there are some slightly bigger changes that are needed because of decisions we made earlier which impact the way the Message
struct is used. I will put up a PR into this branch to try to illustrate what I'm expecting rather than flooding this one with suggestions.
src/types/common.rs
Outdated
@@ -315,7 +327,7 @@ pub enum BaseItemId { | |||
/// The unique identifier of an item. | |||
/// | |||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/itemid> | |||
#[derive(Clone, Debug, Deserialize, XmlSerialize, PartialEq)] | |||
#[derive(Clone, Default, Debug, Deserialize, XmlSerialize, PartialEq)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: Default
doesn't make sense here. See next comment.
src/types/update_item.rs
Outdated
AlwaysOverwrite, | ||
} | ||
|
||
/// Represents a change to an individual item, including the item ID and updates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: This and the other struct comments throughout the file should follow the noun phrase convention.
src/types/update_item.rs
Outdated
pub message: Message, // The new value for the specified field. | ||
} | ||
|
||
/// Struct representing updates to be applied to an item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: "Struct representing" is implicit in the declaration already and doesn't really add anything here.
/// Struct representing updates to be applied to an item. | |
/// A list of changes to fields, with each element representing a single change. |
src/types/update_item.rs
Outdated
|
||
/// Struct representing updates to be applied to an item. | ||
/// | ||
/// This struct is used to create an UpdateItem request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: This doesn't really add anything not implied by the type hierarchy.
src/types/update_item.rs
Outdated
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/updates-item> | ||
#[derive(Clone, Debug, XmlSerialize)] | ||
pub struct Updates { | ||
pub set_item_field: SetItemField, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: A couple problems here. First is that this only allows for a single field to be changed per update and it should instead be a Vec
. Second is that it doesn't allow for append/delete operations. That should be done by using an enum.
src/types/update_item.rs
Outdated
pub item_changes: Vec<ItemChange>, | ||
} | ||
|
||
/// Struct representing the field update operation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: As below, "Struct representing" doesn't add much here, and the second paragraph could easily be folded into this one to give a more complete description, but as below, this needs additional revision.
src/types/update_item.rs
Outdated
impl UpdateItem { | ||
/// Adds another `ItemChange` to the `UpdateItem` request. | ||
pub fn add_item_change(&mut self, item_change: ItemChange) { | ||
self.item_changes.item_changes.push(item_change); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: There's still not really cause to have this be a separate function. The field to be changed is public, so while this provides a slight shortcut to accessing that field, it also provides limited means of interacting with it. In particular, since we generally create these operation structs all at once, push()
isn't very useful as a way of building a list of changes. Instead, we should generally be preferring using Rust iterators and collect()
.
src/types/update_item.rs
Outdated
impl UpdateItem { | ||
/// Adds another `ItemChange` to the `UpdateItem` request. | ||
pub fn add_item_change(&mut self, item_change: ItemChange) { | ||
self.item_changes.item_changes.push(item_change); | ||
} | ||
} | ||
|
||
impl Operation for UpdateItem { | ||
type Response = UpdateItemResponse; | ||
} | ||
|
||
impl EnvelopeBodyContents for UpdateItem { | ||
fn name() -> &'static str { | ||
"UpdateItem" | ||
} | ||
} | ||
|
||
/// A response to an [`UpdateItem`] request. | ||
/// | ||
/// See <https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/updateitemresponse> | ||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct UpdateItemResponse { | ||
pub response_messages: ResponseMessages, | ||
} | ||
|
||
impl OperationResponse for UpdateItemResponse {} | ||
|
||
impl EnvelopeBodyContents for UpdateItemResponse { | ||
fn name() -> &'static str { | ||
"UpdateItemResponse" | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct ResponseMessages { | ||
pub update_item_response_message: Vec<UpdateItemResponseMessage>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct UpdateItemResponseMessage { | ||
/// The status of the corresponding request, i.e. whether it succeeded or | ||
/// resulted in an error. | ||
pub response_class: ResponseClass, | ||
|
||
pub response_code: Option<ResponseCode>, | ||
|
||
pub message_text: Option<String>, | ||
|
||
pub items: Items, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I have generally kept the actual definition of the operations at the beginning of the file with operation-specific types declared below. I don't have solid reasoning for this, but it's consistent and puts the named part of the file up front.
Even nitpickier but reflected in that tendency is that, in Rust, I tend to prefer to declare a type and then declare additional types on which it depends below them, e.g.:
struct Foo {
bar: Bar,
}
struct Bar {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor documentation nit, otherwise lgtm :)
@@ -177,6 +177,18 @@ pub enum DistinguishedPropertySet { | |||
UnifiedMessaging, | |||
} | |||
|
|||
/// The action an Exchange server will take upon creating a `Message` item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The action an Exchange server will take upon creating a `Message` item. | |
/// The action an Exchange server will take upon creating or updating a `Message` item. |
Co-authored-by: Sean Burke <[email protected]>
I put this together for mark read/unread - can you let me know if you would have approached it differently?
I tried to follow create_item and get_item but wasn't sure how much I should be adjusting common.rs vs keeping things local to update_item.rs
Can you maybe give some guidance?