diff --git a/src/types/unsolicited_response.rs b/src/types/unsolicited_response.rs index 6ca6872..c97c910 100644 --- a/src/types/unsolicited_response.rs +++ b/src/types/unsolicited_response.rs @@ -19,32 +19,16 @@ use imap_proto::{ #[derive(Debug, PartialEq, Eq)] #[non_exhaustive] pub enum UnsolicitedResponse { - /// An unsolicited [`STATUS response`](https://tools.ietf.org/html/rfc3501#section-7.2.4). - Status { - /// The mailbox that this status response is for. - mailbox: String, - /// The attributes of this mailbox. - attributes: Vec, - }, - - /// An unsolicited [`RECENT` response](https://tools.ietf.org/html/rfc3501#section-7.3.2) - /// indicating the number of messages with the `\Recent` flag set. This response occurs if the - /// size of the mailbox changes (e.g., new messages arrive). + /// An unsolicited `BYE` response. /// - /// > Note: It is not guaranteed that the message sequence - /// > numbers of recent messages will be a contiguous range of - /// > the highest n messages in the mailbox (where n is the - /// > value reported by the `RECENT` response). Examples of - /// > situations in which this is not the case are: multiple - /// > clients having the same mailbox open (the first session - /// > to be notified will see it as recent, others will - /// > probably see it as non-recent), and when the mailbox is - /// > re-ordered by a non-IMAP agent. - /// > - /// > The only reliable way to identify recent messages is to - /// > look at message flags to see which have the `\Recent` flag - /// > set, or to do a `SEARCH RECENT`. - Recent(u32), + /// The `BYE` response may have an optional `ResponseCode` that provides additional + /// information, per [RFC3501](https://tools.ietf.org/html/rfc3501#section-7.1.5). + Bye { + /// Optional response code. + code: Option, + /// Information text that may be presented to the user. + information: Option, + }, /// An unsolicited [`EXISTS` response](https://tools.ietf.org/html/rfc3501#section-7.3.1) that /// reports the number of messages in the mailbox. This response occurs if the size of the @@ -70,6 +54,26 @@ pub enum UnsolicitedResponse { // TODO: the spec doesn't seem to say anything about when these may be received as unsolicited? Expunge(Seq), + /// An unsolicited `FETCH` response. + /// + /// The server may unilaterally send `FETCH` responses, as described in + /// [RFC3501](https://tools.ietf.org/html/rfc3501#section-7.4.2). + Fetch { + /// Message identifier. + id: u32, + /// Attribute values for this message. + attributes: Vec, + }, + + /// An unsolicited [`FLAGS` response](https://tools.ietf.org/html/rfc3501#section-7.2.6) that + /// identifies the flags (at a minimum, the system-defined flags) that are applicable in the + /// mailbox. Flags other than the system flags can also exist, depending on server + /// implementation. + /// + /// See [`Flag`] for details. + // TODO: the spec doesn't seem to say anything about when these may be received as unsolicited? + Flags(Vec>), + /// An unsolicited METADATA response (https://tools.ietf.org/html/rfc5464#section-4.4.2) /// that reports a change in a server or mailbox annotation. Metadata { @@ -79,6 +83,44 @@ pub enum UnsolicitedResponse { metadata_entries: Vec, }, + /// An unsolicited `OK` response. + /// + /// The `OK` response may have an optional `ResponseCode` that provides additional + /// information, per [RFC3501](https://tools.ietf.org/html/rfc3501#section-7.1.1). + Ok { + /// Optional response code. + code: Option, + /// Information text that may be presented to the user. + information: Option, + }, + + /// An unsolicited [`RECENT` response](https://tools.ietf.org/html/rfc3501#section-7.3.2) + /// indicating the number of messages with the `\Recent` flag set. This response occurs if the + /// size of the mailbox changes (e.g., new messages arrive). + /// + /// > Note: It is not guaranteed that the message sequence + /// > numbers of recent messages will be a contiguous range of + /// > the highest n messages in the mailbox (where n is the + /// > value reported by the `RECENT` response). Examples of + /// > situations in which this is not the case are: multiple + /// > clients having the same mailbox open (the first session + /// > to be notified will see it as recent, others will + /// > probably see it as non-recent), and when the mailbox is + /// > re-ordered by a non-IMAP agent. + /// > + /// > The only reliable way to identify recent messages is to + /// > look at message flags to see which have the `\Recent` flag + /// > set, or to do a `SEARCH RECENT`. + Recent(u32), + + /// An unsolicited [`STATUS response`](https://tools.ietf.org/html/rfc3501#section-7.2.4). + Status { + /// The mailbox that this status response is for. + mailbox: String, + /// The attributes of this mailbox. + attributes: Vec, + }, + /// An unsolicited [`VANISHED` response](https://tools.ietf.org/html/rfc7162#section-3.2.10) /// that reports a sequence-set of `UID`s that have been expunged from the mailbox. /// @@ -104,48 +146,6 @@ pub enum UnsolicitedResponse { /// The list of `UID`s which have been removed uids: Vec>, }, - - /// An unsolicited [`FLAGS` response](https://tools.ietf.org/html/rfc3501#section-7.2.6) that - /// identifies the flags (at a minimum, the system-defined flags) that are applicable in the - /// mailbox. Flags other than the system flags can also exist, depending on server - /// implementation. - /// - /// See [`Flag`] for details. - // TODO: the spec doesn't seem to say anything about when these may be received as unsolicited? - Flags(Vec>), - - /// An unsolicited `OK` response. - /// - /// The `OK` response may have an optional `ResponseCode` that provides additional - /// information, per [RFC3501](https://tools.ietf.org/html/rfc3501#section-7.1.1). - Ok { - /// Optional response code. - code: Option, - /// Information text that may be presented to the user. - information: Option, - }, - - /// An unsolicited `BYE` response. - /// - /// The `BYE` response may have an optional `ResponseCode` that provides additional - /// information, per [RFC3501](https://tools.ietf.org/html/rfc3501#section-7.1.5). - Bye { - /// Optional response code. - code: Option, - /// Information text that may be presented to the user. - information: Option, - }, - - /// An unsolicited `FETCH` response. - /// - /// The server may unilaterally send `FETCH` responses, as described in - /// [RFC3501](https://tools.ietf.org/html/rfc3501#section-7.4.2). - Fetch { - /// Message identifier. - id: u32, - /// Attribute values for this message. - attributes: Vec, - }, } /// Try to convert from a `imap_proto::Response`.