jmap_client/thread/
mod.rs

1/*
2 * Copyright Stalwart Labs LLC See the COPYING
3 * file at the top-level directory of this distribution.
4 *
5 * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 * https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 * <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
8 * option. This file may not be copied, modified, or distributed
9 * except according to those terms.
10 */
11
12pub mod get;
13pub mod helpers;
14
15use std::fmt::Display;
16
17use serde::{Deserialize, Serialize};
18
19use crate::core::{changes::ChangesObject, Object};
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct Thread {
23    id: String,
24    #[serde(rename = "emailIds")]
25    email_ids: Vec<String>,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Copy)]
29pub enum Property {
30    #[serde(rename = "id")]
31    Id,
32    #[serde(rename = "emailIds")]
33    EmailIds,
34}
35
36impl Object for Thread {
37    type Property = Property;
38
39    fn requires_account_id() -> bool {
40        true
41    }
42}
43
44impl Display for Property {
45    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46        match self {
47            Property::Id => write!(f, "id"),
48            Property::EmailIds => write!(f, "emailIds"),
49        }
50    }
51}
52
53impl ChangesObject for Thread {
54    type ChangesResponse = ();
55}