Skip to content

Add typestate write operations to ProtonClient#17

Merged
dannywillems merged 2 commits intomasterfrom
add-typestate-write-operations
Feb 9, 2026
Merged

Add typestate write operations to ProtonClient#17
dannywillems merged 2 commits intomasterfrom
add-typestate-write-operations

Conversation

@dannywillems
Copy link
Contributor

Summary

  • Introduce typestate pattern on ProtonClient<M> where M is ReadOnly (default) or ReadWrite, enforcing access control at compile time
  • Add write operations: move_to_folder, add_flag, remove_flag, archive, unmark_all_read (only available on ProtonClient<ReadWrite>)
  • Extract shared TLS/connection logic into connection.rs and add Flag enum in flag.rs
  • Update fake IMAP server with STORE, COPY, EXPUNGE handlers and Arc<Mutex<Mailbox>> for mutable state
  • Add integration tests for all write operations (130 total tests passing)

Test plan

  • All 130 tests pass (cargo test)
  • Clippy clean (cargo clippy --all-targets)
  • Formatting clean (cargo +nightly fmt -- --check)
  • No trailing whitespace

Introduce a type parameter M on ProtonClient<M> that controls
access at compile time:

- ProtonClient<ReadOnly> (default): read operations only
- ProtonClient<ReadWrite>: read + write operations

Write operations added: move_to_folder, add_flag, remove_flag,
archive, unmark_all_read. Extract shared TLS/connection logic
into connection.rs and add Flag enum in flag.rs.

Update fake IMAP server to support STORE, COPY, and EXPUNGE
commands with Arc<Mutex<Mailbox>> for shared mutable state.
Add integration tests for all write operations.
@dannywillems dannywillems force-pushed the add-typestate-write-operations branch 2 times, most recently from a20bce0 to d8dd154 Compare February 9, 2026 16:20
Add three compile_fail doctests proving ProtonClient<ReadOnly>
cannot call write methods (add_flag, move_to_folder, archive).
The main module doctest keeps no_run since it calls from_env()
which requires IMAP env vars at runtime.

Remove all #[allow(clippy::...)] annotations by fixing the
underlying issues: extract dispatch_command to reduce line count,
introduce StoreArgs struct to reduce argument count, and inline
MutexGuard usage to satisfy significant_drop_tightening.
@dannywillems dannywillems force-pushed the add-typestate-write-operations branch from 49c8674 to 51341f6 Compare February 9, 2026 16:26
@dannywillems dannywillems merged commit 3ab618a into master Feb 9, 2026
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.

1 participant