Skip to content

Tidy PyToBytes into a helper; document data models and attachments behavior#87

Merged
kurok merged 1 commit into
masterfrom
fix-issues-29-53-54-rust-tidy-docs
Jun 12, 2026
Merged

Tidy PyToBytes into a helper; document data models and attachments behavior#87
kurok merged 1 commit into
masterfrom
fix-issues-29-53-54-rust-tidy-docs

Conversation

@kurok

@kurok kurok commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Three non-breaking tidy/documentation changes. No public behavior or API change; the full test suite passes unchanged.

Changes

  • Replace single-use PyToBytes trait with a private helper #29 (tech-debt): Replace the single-use PyToBytes trait (implemented only for Py<PyAny>, called once in parse_email) with a plain private payload_to_bytes(&Py<PyAny>, Python<'_>) helper. Identical logic: bytes used as-is, str decoded as its UTF-8 bytes, any other type raises TypeError.
  • Document attachments-contains-all-parts behavior; add Rust doc-comments #53 (docs): Document that PyMail.attachments contains every node of the MIME tree -- text parts and the multipart container nodes themselves (containers have empty content) -- not just file attachments. Documents existing behavior; nothing changed.
  • Document the two parallel data models (PyO3-free core split) #54 (docs/tech-debt): Add module-level doc-comments explaining the two parallel data models: src/mail_parser.rs is the PyO3-free core (Mail/Attachment, independently testable) and src/fast_mail_parser.rs is the PyO3 binding layer (PyMail/PyAttachment). Notes why the split exists (keeps parsing decoupled from the Python bindings).

Verification

  • cargo fmt --all -- --check passes
  • cargo clippy --all-targets -- -D warnings -W clippy::cast_possible_truncation clean
  • pytest -q --ignore tests/benchmark tests: 91 passed

Closes #29
Closes #53
Closes #54

…s and attachments behavior

- #29: replace the single-use PyToBytes trait (implemented only for
  Py<PyAny>, called once) with a plain private payload_to_bytes helper.
  Same logic: bytes used as-is, str decoded as UTF-8, otherwise TypeError.
- #53: document that PyMail.attachments holds every MIME-tree node (text
  parts and multipart container nodes with empty content), not just files.
- #54: add module doc-comments describing the PyO3-free core (mail_parser)
  vs the PyO3 binding layer (fast_mail_parser) and why they are separate.

No public behavior or API change.

Signed-off-by: yuriyryabikov <22548029+kurok@users.noreply.github.com>
@kurok kurok merged commit b911c27 into master Jun 12, 2026
7 checks passed
@kurok kurok deleted the fix-issues-29-53-54-rust-tidy-docs branch June 12, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant