djc / tokio-imap

Tokio-based IMAP implementation
Apache License 2.0
123 stars 42 forks source link

Add support for RFC7162 (QRESYNC) VANISHED response. #101

Closed mordak closed 3 years ago

mordak commented 3 years ago

RFC7162 defines a VANISHED response to the EXPUNGE command which must be used whenever a client has enabled QRESYNC. VANISHED may also appear in response to SELECT/EXAMINE or UID FETCH.

https://tools.ietf.org/html/rfc7162#section-3.2.10

The VANISHED response sends a sequence set of UIDs indicating UIDs which have been deleted from the mailbox.

I had to add parsers for sequence-range (eg 15:30) and sequence-set (eg. 1,10:20,25,28:31), and I put them in core.rs since they are actually defined in RFC 3501 and show up in a couple of other places, so may be generically useful.

I am not sure if the choice to return a Vec<RangeInclusive> is to your liking. Alternatives could be just a tuple of (start, end), or expand the range out into a big list of Vec<u32>. I experimented with both options and settled on the Vec<RangeInclusive> because:

The downside is it can be a bit awkward to use, since you end up iterating a list of iterators. Of course, the nicest way to represent this for the user is to expand the sequence set out into a Vec<u32>, but this could be wasteful / dangerous in some circumstances.

djc commented 3 years ago

This is great, thanks! Would it be helpful to get a release including this?

mordak commented 3 years ago

Would it be helpful to get a release including this?

A release including this would be helpful, yes! :-)

djc commented 3 years ago

0.12.0 is out now.

mordak commented 3 years ago

0.12.0 is out now.

Thank you! Just opened the domino PR for rust-imap: https://github.com/jonhoo/rust-imap/pull/172

And then my IMAP <-> Maildir sync engine will actually build against public crates!