Skip to main content

Email

Struct Email 

Source
#[non_exhaustive]
pub struct Email {
Show 27 fields pub id: Id, pub blob_id: Id, pub thread_id: Id, pub mailbox_ids: HashMap<Id, bool>, pub keywords: HashMap<Keyword, bool>, pub size: u64, pub received_at: UTCDate, pub message_id: Option<Vec<String>>, pub in_reply_to: Option<Vec<String>>, pub references: Option<Vec<String>>, pub sender: Option<Vec<EmailAddress>>, pub from: Option<Vec<EmailAddress>>, pub to: Option<Vec<EmailAddress>>, pub cc: Option<Vec<EmailAddress>>, pub bcc: Option<Vec<EmailAddress>>, pub reply_to: Option<Vec<EmailAddress>>, pub subject: Option<String>, pub sent_at: Option<Date>, pub headers: Vec<EmailHeader>, pub body_values: HashMap<String, EmailBodyValue>, pub text_body: Vec<EmailBodyPart>, pub html_body: Vec<EmailBodyPart>, pub attachments: Vec<EmailBodyPart>, pub body_structure: Option<EmailBodyPart>, pub has_attachment: bool, pub preview: Option<String>, pub extra: Map<String, Value>,
}
Expand description

An Email object (RFC 8621 §4.1).

Combines metadata (§4.1.1), parsed header convenience properties (§4.1.3), and body fields (§4.1.4).

§Full vs partial responses

This type is designed for full Email/get responses where all metadata properties are present. The metadata fields blob_id, thread_id, mailbox_ids, size, and received_at are required (non-Option); deserialization fails if any of them is absent from the JSON.

RFC 8621 §4.5 allows clients to request only a subset of properties. If a partial response omits any required metadata field, serde_json::from_str will return a “missing field” error. For partial-property responses, deserialize into serde_json::Value first or define a narrower type with all fields Option.

Header convenience properties (§4.1.3) and body fields (§4.1.4) are all Option; they deserialize as None when not included in the response.

§Serialization caveat for server implementors

Several collection fields (keywords, body_values, text_body, html_body, attachments, headers) use #[serde(skip_serializing_if = "…::is_empty")]. This is correct for partial responses — a property not in the client’s properties list MUST be absent from the response. However, RFC 8621 §4.1.1 defines keywords with default: {}, meaning a server MUST include "keywords":{} in the response when the property was requested and the email has no keywords.

Do not rely on serde_json::to_value(email) to produce RFC-compliant JSON for full-object responses. Server code in jmap-mail-server must explicitly populate any collection fields that are in the requested properties set before serialization, or use a custom serializer that includes them.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: Id

The JMAP object id of this Email.

§blob_id: Id

Blob id of the raw RFC 5322 message octets.

§thread_id: Id

Id of the Thread this Email belongs to.

§mailbox_ids: HashMap<Id, bool>

Set of Mailbox ids this Email belongs to.

Represented as HashMap<Id, bool> because the JMAP wire format uses a JSON object with boolean values (RFC 8621 §4.1.1). Values are always true in full-object responses; the map shape is also used in PatchObject updates (RFC 8620 §5.3) where a null value removes an entry.

§keywords: HashMap<Keyword, bool>

Keywords applied to this Email.

Same JSON object shape as mailbox_ids (string keys, boolean values) — JMAP wire format requirement. Keys are Keyword values (not JMAP Ids); system keywords start with $ which is not valid inside a JMAP Id (RFC 8620 §1.2). Values are always true in full-object responses (RFC 8621 §4.1.1).

§size: u64

Size in octets of the raw RFC 5322 message.

§received_at: UTCDate

Date the Email was received by the message store.

§message_id: Option<Vec<String>>

Value of the Message-ID header field as a list of message ids.

§in_reply_to: Option<Vec<String>>

Value of the In-Reply-To header field as a list of message ids.

§references: Option<Vec<String>>

Value of the References header field as a list of message ids.

§sender: Option<Vec<EmailAddress>>

Parsed addresses from the Sender header field.

§from: Option<Vec<EmailAddress>>

Parsed addresses from the From header field.

§to: Option<Vec<EmailAddress>>

Parsed addresses from the To header field.

§cc: Option<Vec<EmailAddress>>

Parsed addresses from the Cc header field.

§bcc: Option<Vec<EmailAddress>>

Parsed addresses from the Bcc header field.

§reply_to: Option<Vec<EmailAddress>>

Parsed addresses from the Reply-To header field.

§subject: Option<String>

Decoded text value of the Subject header field.

§sent_at: Option<Date>

Parsed value of the Date header field (RFC 8621 §4.1.3).

Type Date (any RFC 3339 timezone offset) per the RFC. Email Date headers commonly carry non-UTC offsets such as "+10:00".

§headers: Vec<EmailHeader>

All header fields of the message in Raw form, in order.

§body_values: HashMap<String, EmailBodyValue>

Map from partId to decoded text content for text body parts.

§text_body: Vec<EmailBodyPart>

Text body parts to display, preferring text/plain.

§html_body: Vec<EmailBodyPart>

HTML body parts to display, preferring text/html.

§attachments: Vec<EmailBodyPart>

All attachment parts (depth-first, excluding subParts).

§body_structure: Option<EmailBodyPart>

Full MIME body structure of the message.

§has_attachment: bool

True if there is at least one downloadable attachment.

§preview: Option<String>

Short plaintext preview of the message body (≤256 characters).

§extra: Map<String, Value>

Catch-all for vendor / site / private extension fields not covered by the typed fields above. Preserves unknown fields across deserialize/serialize round-trip per workspace extras-preservation policy (see workspace AGENTS.md).

Implementations§

Source§

impl Email

Source

pub fn new( id: Id, blob_id: Id, thread_id: Id, mailbox_ids: HashMap<Id, bool>, size: u64, received_at: UTCDate, ) -> Self

Construct an Email from its six required metadata fields.

All parsed-header and body fields default to None / empty.

Trait Implementations§

Source§

impl Clone for Email

Source§

fn clone(&self) -> Email

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Email

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Email

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Email

Source§

impl GetObject for Email

Source§

impl JmapObject for Email

Source§

const TYPE_NAME: &'static str = "Email"

The JMAP type name string (e.g. "Email", "Mailbox", "Chat").
Source§

type Property = EmailProperty

The property selector enum for this type (server-side only, no serde).
Source§

impl PartialEq for Email

Source§

fn eq(&self, other: &Email) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl QueryObject for Email

Source§

type Filter = Filter<EmailFilterCondition>

The filter condition type. Read more
Source§

type Comparator = EmailComparator

The comparator type for sort operations.
Source§

impl Serialize for Email

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SetObject for Email

Source§

type Patch = PatchObject

The patch type for update operations. Read more
Source§

impl StructuralPartialEq for Email

Auto Trait Implementations§

§

impl Freeze for Email

§

impl RefUnwindSafe for Email

§

impl Send for Email

§

impl Sync for Email

§

impl Unpin for Email

§

impl UnsafeUnpin for Email

§

impl UnwindSafe for Email

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.