Skip to content

refactor(server): replace classify_uid Option<Option<u32>> with enum#381

Merged
randomparity merged 1 commit into
mainfrom
refactor/server-preflight-size-enum-342
May 29, 2026
Merged

refactor(server): replace classify_uid Option<Option<u32>> with enum#381
randomparity merged 1 commit into
mainfrom
refactor/server-preflight-size-enum-342

Conversation

@randomparity
Copy link
Copy Markdown
Owner

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.

This introduces 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, 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-features clean (suppression removed, no option_option)
  • 23 export_messages tests pass, including the six classify_uid_cases assertions remapped onto the enum
  • cargo doc --no-deps --document-private-items shows zero export_messages.rs warnings

Closes #342

🤖 Generated with Claude Code

`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
@randomparity randomparity merged commit 912b6a0 into main May 29, 2026
12 checks passed
@randomparity randomparity deleted the refactor/server-preflight-size-enum-342 branch May 29, 2026 14:45
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.

refactor(server): replace classify_uid Option<Option<u32>> with an enum

1 participant