Skip to content

feat: add quirk to dedup and sort sequence sets during encoding#691

Open
soywod wants to merge 4 commits intoduesee:mainfrom
soywod:quirk-dedup-sort-seq-encoding
Open

feat: add quirk to dedup and sort sequence sets during encoding#691
soywod wants to merge 4 commits intoduesee:mainfrom
soywod:quirk-dedup-sort-seq-encoding

Conversation

@soywod
Copy link
Contributor

@soywod soywod commented Jan 23, 2026

Closes #689.

@soywod soywod force-pushed the quirk-dedup-sort-seq-encoding branch from bb9e0f5 to d69ebe4 Compare January 23, 2026 15:34
@soywod
Copy link
Contributor Author

soywod commented Jan 23, 2026

Looks like the feature breaks things, I will need more time to adjust. I would like to know first if you agree with the proposition.

@duesee
Copy link
Owner

duesee commented Jan 23, 2026

This is going in the right direction! I think that our structured fuzzer will break due to this, but I propose we first don't care about that here. We should maybe add an issue to also account for this quirk during fuzzing but I can take care of that later.

Thanks to your unit tests, I think that we can make the best of this quirk by making it a nice generic feature. Curious what you think.

By the way, I'll be on vacation for a fee weeks. But I'll try to have a look here now and then.

@soywod soywod force-pushed the quirk-dedup-sort-seq-encoding branch from 4351bcb to 71f5ba0 Compare January 26, 2026 20:48
@soywod
Copy link
Contributor Author

soywod commented Jan 26, 2026

I pushed a new version in another commit so you can see the difference. I will squash before merging. I moved the logic into normalize functions inside imap-types (for Sequence and SequenceSet). The quirk remains in imap-codec and just call the normalize function before encoding. Few questions at the top of my head:

  • There is so many ways to declare such function, I opted for the pub fn normalize(&mut self) -> &mut Self on both Sequence and SequenceSet, but I don't have solid arguments about this choice.
  • With these new functions, should the normalization should remains at encoding level or at declaration?

@soywod
Copy link
Contributor Author

soywod commented Jan 26, 2026

I also added more cases to the normalization, for exemple range a:a to single a, single asterisk to range 1:asterisk (because not all IMAP server like the * only, 1:* seems to be the safest as most understood in general) etc. See tests.

@coveralls
Copy link
Collaborator

coveralls commented Feb 5, 2026

Pull Request Test Coverage Report for Build 21943312117

Details

  • 184 of 188 (97.87%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 91.324%

Changes Missing Coverage Covered Lines Changed/Added Lines %
imap-types/src/sequence.rs 178 182 97.8%
Totals Coverage Status
Change from base Build 19733249334: 0.1%
Covered Lines: 10557
Relevant Lines: 11560

💛 - Coveralls

@soywod
Copy link
Contributor Author

soywod commented Feb 5, 2026

Ready for another review. I am not so happy about the implementation, but I don't see yet how to improve it.

@soywod soywod requested a review from duesee February 5, 2026 13:06
@soywod soywod force-pushed the quirk-dedup-sort-seq-encoding branch 5 times, most recently from 01cc5e1 to 3ce5a4b Compare February 8, 2026 13:31
@soywod soywod force-pushed the quirk-dedup-sort-seq-encoding branch from 3ce5a4b to 49a1074 Compare February 8, 2026 13:42
@soywod
Copy link
Contributor Author

soywod commented Feb 8, 2026

Finally, CI happy 😄

@duesee
Copy link
Owner

duesee commented Feb 10, 2026

Wow! This looks so much better! Thanks! Let me do a proper review tomorrow evening :-)

Copy link
Owner

@duesee duesee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is still an improvement to make so that x:y,y:z is merged into x:z. But since this is a vast improvement already (and I know that you need the change :-)), I'll let you decide to merge as is. Can do a release later today.

@soywod
Copy link
Contributor Author

soywod commented Feb 12, 2026

A condition was not properly set, see cfba643. Now it merges properly contiguous ranges. Ready for another review.

@soywod soywod requested a review from duesee February 12, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add quirk to sort sequence sets

3 participants