Skip to main content

jmap_mail_types/
thread.rs

1//! RFC 8621 §3 Thread object.
2//!
3//! Provides [`Thread`] — groups related [`crate::Email`] objects by
4//! conversation thread.
5
6use jmap_types::Id;
7use serde::{Deserialize, Serialize};
8
9/// A Thread object as defined in RFC 8621 §3.
10///
11/// Groups related Email objects by conversation thread. The `emailIds` field
12/// lists member Email ids sorted oldest-first by `receivedAt`.
13#[non_exhaustive]
14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
15#[serde(rename_all = "camelCase")]
16pub struct Thread {
17    /// The id of the Thread (immutable; server-set).
18    pub id: Id,
19    /// The ids of the Emails in the Thread, sorted oldest-first by `receivedAt` (server-set).
20    pub email_ids: Vec<Id>,
21}
22
23impl Thread {
24    /// Construct a [`Thread`] from its two required fields.
25    pub fn new(id: Id, email_ids: Vec<Id>) -> Self {
26        Self { id, email_ids }
27    }
28}