calternal_imap::mime
Bounded MIME descriptions and exact body sections (#897/#486, DESIGN §53) with Apple Note validation kept at the Notes boundary (#428 D9). Accepted wrapper spelling and MIME bytes remain inert raw data for per-User internal state. Parts have CID identities, never client filenames or filesystem paths. The Markdown writer decides where a new attachment belongs; this module performs no filesystem access.
Source: crates/calternal-imap/src/mime.rs
Structs
Section titled “Structs”Attachment
Section titled “Attachment”pub struct AttachmentA CID part has no client-controlled filesystem path or replayed active HTML.
Fields
pub cid: Stringpub media_type: Stringpub bytes: Vec<u8>
Implements: Clone, Debug, PartialEq, Eq
Source: crates/calternal-imap/src/mime.rs:35
MimeLimits
Section titled “MimeLimits”pub struct MimeLimitsMIME resource limits applied independently of IMAP framing. Input bytes are bounded before parsing; decoded bytes and part count are checked before copy.
Fields
pub max_message_bytes: usizepub max_parts: usizepub max_decoded_bytes: usizepub max_header_bytes: usize
Implements: Clone, Copy, Default
Source: crates/calternal-imap/src/mime.rs:16
NoteMessage
Section titled “NoteMessage”pub struct NoteMessageRaw MIME is retained for D9 replay separately from authoritative Markdown.
Fields
pub identity: Stringpub html: Stringpub raw: Vec<u8>pub attachments: Vec<Attachment>
Implements: Clone, Debug
NoteMessage::parse
Section titled “NoteMessage::parse”pub fn parse(raw: &[u8], limits: MimeLimits) -> Result<Self, &'static str>Parse only an identified Apple Note with one HTML body. Reject duplicate identities, corrupt transfer encodings, active HTML and ambiguous CIDs.
NoteMessage::render
Section titled “NoteMessage::render”pub fn render( identity_value: &str, html: &str, attachments: &[Attachment], limits: MimeLimits, ) -> Result<Vec<u8>, &'static str>Make a safe related message with base64 bodies. Boundary text cannot
occur in base64 data. Only static image types and PDF are projected.
This form has no Subject or Date; the Notes bridge uses
NoteMessage::render_note, which Apple Notes needs to show a Note.
NoteMessage::render_note
Section titled “NoteMessage::render_note”pub fn render_note( identity_value: &str, date: i64, html: &str, attachments: &[Attachment], limits: MimeLimits, ) -> Result<Vec<u8>, &'static str>Render a Note the way Apple Notes writes its own messages (#428 live
Mac run): a Subject equal to the first visible line, a Date, and a
complete <html><body> document. Without these the Mac lists the Note
with no title and an empty body. date is Unix seconds (UTC).
Source: crates/calternal-imap/src/mime.rs:43
BodySection
Section titled “BodySection”pub enum BodySectionWhich exact encoded slice a BODY section requests (#486, DESIGN §53).
Variants
BodyHeaderMimeText
Implements: Clone, Copy
Source: crates/calternal-imap/src/mime.rs:416
Functions
Section titled “Functions”apple_created_date
Section titled “apple_created_date”pub fn apple_created_date(raw: &[u8]) -> Option<i64>Read Apple’s X-Mail-Created-Date as Unix seconds. macOS 27 Notes 4.13
can retain its initial Date over several local saves (#644 live Mac).
The provider must resolve it to immutable served evidence, never assume
that it is the current revision. Absent or malformed values prove nothing.
Source: crates/calternal-imap/src/mime.rs:681
body_section
Section titled “body_section”pub fn body_section( raw: &[u8], path: &[u32], section: BodySection,) -> Result<Option<Vec<u8>>, &'static str>Read bounded MIME part coordinates without decoding leaf wire bytes. Missing parts return NIL. Embedded-message header and text requests use the nested message, while MIME requests use the enclosing part header.
Source: crates/calternal-imap/src/mime.rs:426
bodystructure
Section titled “bodystructure”pub fn bodystructure(raw: &[u8]) -> Result<String, &'static str>Describe ordinary Mail and generated Notes without Note-only validation (#897, DESIGN §53). Bound bytes before parsing, then bound parts and headers. Parameters and encodings describe the wire bytes, not decoded content.
Source: crates/calternal-imap/src/mime.rs:506
envelope
Section titled “envelope”pub fn envelope(headers: &[u8]) -> Result<String, &'static str>Build client envelope metadata from exact outer headers without body bytes (#684/#486, DESIGN §53). The shared sync header limit bounds parsing.