refactor(server): replace classify_uid Option<Option<u32>> with enum#381
Merged
Merged
Conversation
`classify_uid` took `Option<Option<u32>>` to encode three states (absent
/ present-size-unknown / present-size-known), carrying an
`#[expect(clippy::option_option)]` and a doc admitting a custom enum
would be clearer.
Introduce `enum PreflightSize { Absent, PresentUnknown, Present(u32) }`.
`preflight_sizes` now builds a `BTreeMap<u32, PreflightSize>` holding
only present states (`PresentUnknown` / `Present`); a lookup miss maps to
`Absent` at the two call sites. `classify_uid` matches the three variants
directly, dropping the nested `Option` and the suppression. The
`fetch_sizes` trait and IMAP layer are untouched.
Behavior is unchanged: the NotFound/Oversize gating and the eligible-sum
budget pre-check map state-for-state onto the prior encoding.
Closes #342
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
classify_uidtookOption<Option<u32>>to encode three states (absent / present-size-unknown / present-size-known), carrying an#[expect(clippy::option_option)]and a doc admitting a custom enum would be clearer.This introduces
enum PreflightSize { Absent, PresentUnknown, Present(u32) }.preflight_sizesnow builds aBTreeMap<u32, PreflightSize>holding only present states (PresentUnknown/Present); a lookup miss maps toAbsentat the two call sites.classify_uidmatches the three variants directly, dropping the nestedOptionand the suppression. Thefetch_sizestrait and IMAP layer are untouched, per the issue.Behavior is unchanged: the security-relevant NotFound/Oversize gating and the eligible-sum budget pre-check map state-for-state onto the prior encoding (verified by an adversarial review of every input case and the boundary at
size == per_msg_cap).Verification:
cargo clippy -p rimap-server --all-targets --all-featuresclean (suppression removed, nooption_option)export_messagestests pass, including the sixclassify_uid_casesassertions remapped onto the enumcargo doc --no-deps --document-private-itemsshows zeroexport_messages.rswarningsCloses #342
🤖 Generated with Claude Code