jmap_client/identity/
set.rs1use crate::{core::set::SetObject, email::EmailAddress, Get, Set};
13
14use super::Identity;
15
16impl Identity<Set> {
17 pub fn name(&mut self, name: impl Into<String>) -> &mut Self {
18 self.name = Some(name.into());
19 self
20 }
21
22 pub fn email(&mut self, email: impl Into<String>) -> &mut Self {
23 self.email = Some(email.into());
24 self
25 }
26
27 pub fn bcc<T, U>(&mut self, bcc: Option<T>) -> &mut Self
28 where
29 T: Iterator<Item = U>,
30 U: Into<EmailAddress>,
31 {
32 self.bcc = bcc.map(|s| s.map(|s| s.into()).collect());
33 self
34 }
35
36 pub fn reply_to<T, U>(&mut self, reply_to: Option<T>) -> &mut Self
37 where
38 T: Iterator<Item = U>,
39 U: Into<EmailAddress>,
40 {
41 self.reply_to = reply_to.map(|s| s.map(|s| s.into()).collect());
42 self
43 }
44
45 pub fn text_signature(&mut self, text_signature: impl Into<String>) -> &mut Self {
46 self.text_signature = Some(text_signature.into());
47 self
48 }
49
50 pub fn html_signature(&mut self, html_signature: impl Into<String>) -> &mut Self {
51 self.html_signature = Some(html_signature.into());
52 self
53 }
54}
55
56impl SetObject for Identity<Set> {
57 type SetArguments = ();
58
59 fn new(_create_id: Option<usize>) -> Self {
60 Identity {
61 _create_id,
62 _state: Default::default(),
63 id: None,
64 name: None,
65 email: None,
66 reply_to: Vec::with_capacity(0).into(),
67 bcc: Vec::with_capacity(0).into(),
68 text_signature: None,
69 html_signature: None,
70 may_delete: None,
71 }
72 }
73
74 fn create_id(&self) -> Option<String> {
75 self._create_id.map(|id| format!("c{}", id))
76 }
77}
78
79impl SetObject for Identity<Get> {
80 type SetArguments = ();
81
82 fn new(_create_id: Option<usize>) -> Self {
83 unimplemented!()
84 }
85
86 fn create_id(&self) -> Option<String> {
87 None
88 }
89}