#[non_exhaustive]
pub enum UnsolicitedResponse {
    Bye {
        code: Option<ResponseCode<'static>>,
        information: Option<String>,
    },
    Exists(u32),
    Expunge(Seq),
    Fetch {
        id: u32,
        attributes: Vec<AttributeValue<'static>>,
    },
    Flags(Vec<Flag<'static>>),
    Metadata {
        mailbox: String,
        metadata_entries: Vec<String>,
    },
    Ok {
        code: Option<ResponseCode<'static>>,
        information: Option<String>,
    },
    Recent(u32),
    Status {
        mailbox: String,
        attributes: Vec<StatusAttribute>,
    },
    Vanished {
        earlier: bool,
        uids: Vec<RangeInclusive<u32>>,
    },
}
Expand description

Responses that the server sends that are not related to the current command. RFC 3501 states that clients need to be able to accept any response at any time.

Not all possible responses are explicitly enumerated here because in practice only some types of responses are delivered as unsolicited responses. If you encounter an unsolicited response in the wild that is not handled here, please open an issue and let us know!

Note that Recent, Exists and Expunge responses refer to the currently SELECTed folder, so the user must take care when interpreting these.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Bye

Fields

§code: Option<ResponseCode<'static>>

Optional response code.

§information: Option<String>

Information text that may be presented to the user.

An unsolicited BYE response.

The BYE response may have an optional ResponseCode that provides additional information, per RFC3501.

§

Exists(u32)

An unsolicited EXISTS response that reports the number of messages in the mailbox. This response occurs if the size of the mailbox changes (e.g., new messages arrive).

§

Expunge(Seq)

An unsolicited EXPUNGE response that reports that the specified message sequence number has been permanently removed from the mailbox. The message sequence number for each successive message in the mailbox is immediately decremented by 1, and this decrement is reflected in message sequence numbers in subsequent responses (including other untagged EXPUNGE responses).

The EXPUNGE response also decrements the number of messages in the mailbox; it is not necessary to send an EXISTS response with the new value.

As a result of the immediate decrement rule, message sequence numbers that appear in a set of successive EXPUNGE responses depend upon whether the messages are removed starting from lower numbers to higher numbers, or from higher numbers to lower numbers. For example, if the last 5 messages in a 9-message mailbox are expunged, a “lower to higher” server will send five untagged EXPUNGE responses for message sequence number 5, whereas a “higher to lower server” will send successive untagged EXPUNGE responses for message sequence numbers 9, 8, 7, 6, and 5.

§

Fetch

Fields

§id: u32

Message identifier.

§attributes: Vec<AttributeValue<'static>>

Attribute values for this message.

An unsolicited FETCH response.

The server may unilaterally send FETCH responses, as described in RFC3501.

§

Flags(Vec<Flag<'static>>)

An unsolicited FLAGS response 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.

§

Metadata

Fields

§mailbox: String

Mailbox name for which annotations were changed.

§metadata_entries: Vec<String>

List of annotations that were changed.

An unsolicited METADATA response (https://tools.ietf.org/html/rfc5464#section-4.4.2) that reports a change in a server or mailbox annotation.

§

Ok

Fields

§code: Option<ResponseCode<'static>>

Optional response code.

§information: Option<String>

Information text that may be presented to the user.

An unsolicited OK response.

The OK response may have an optional ResponseCode that provides additional information, per RFC3501.

§

Recent(u32)

An unsolicited RECENT response 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.

§

Status

Fields

§mailbox: String

The mailbox that this status response is for.

§attributes: Vec<StatusAttribute>

The attributes of this mailbox.

An unsolicited STATUS response.

§

Vanished

Fields

§earlier: bool

Whether the EARLIER tag was set on the response

§uids: Vec<RangeInclusive<u32>>

The list of UIDs which have been removed

An unsolicited VANISHED response that reports a sequence-set of UIDs that have been expunged from the mailbox.

The VANISHED response is similar to the EXPUNGE response and can be sent wherever an EXPUNGE response can be sent. It can only be sent by the server if the client has enabled QRESYNC.

The VANISHED response has two forms, one with the EARLIER tag which is used to respond to a UID FETCH or SELECT/EXAMINE command, and one without an EARLIER tag, which is used to announce removals within an already selected mailbox.

If using QRESYNC, the client can fetch new, updated and deleted UIDs in a single round trip by including the (CHANGEDSINCE <MODSEQ> VANISHED) modifier to the UID SEARCH command, as described in RFC7162. For example UID FETCH 1:* (UID FLAGS) (CHANGEDSINCE 1234 VANISHED) would return FETCH results for all UIDs added or modified since MODSEQ 1234. Deleted UIDs will be present as a VANISHED response in the Session::unsolicited_responses channel.

Trait Implementations§

Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Try to convert from a imap_proto::Response.

Not all Response variants are supported - only those which are known or likely to be sent by a server as a unilateral response during normal operations or during an IDLE session are implented.

If the conversion fails, the input Reponse is returned.

The type returned in the event of a conversion error.
Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.