pub struct Changes { /* private fields */ }
Implementations§
Source§impl Changes
impl Changes
pub fn new( id: Option<String>, changes: AHashMap<String, AHashMap<TypeState, String>>, ) -> Self
Sourcepub fn id(&self) -> Option<&str>
pub fn id(&self) -> Option<&str>
Examples found in repository?
examples/eventsource.rs (line 51)
22async fn event_source() {
23 // Connect to the JMAP server using Basic authentication
24 let client = Client::new()
25 .credentials(("john@example.org", "secret"))
26 .connect("https://jmap.example.org")
27 .await
28 .unwrap();
29
30 // Open EventSource connection
31 let mut stream = client
32 .event_source(
33 [
34 TypeState::Email,
35 TypeState::EmailDelivery,
36 TypeState::Mailbox,
37 TypeState::EmailSubmission,
38 TypeState::Identity,
39 ]
40 .into(),
41 false,
42 60.into(),
43 None,
44 )
45 .await
46 .unwrap();
47
48 // Consume events
49 while let Some(event) = stream.next().await {
50 let changes = event.unwrap();
51 println!("-> Change id: {:?}", changes.id());
52 for account_id in changes.changed_accounts() {
53 println!(" Account {} has changes:", account_id);
54 if let Some(account_changes) = changes.changes(account_id) {
55 for (type_state, state_id) in account_changes {
56 println!(" Type {:?} has a new state {}.", type_state, state_id);
57 }
58 }
59 }
60 }
61}
pub fn account_changes( &mut self, account_id: &str, ) -> Option<AHashMap<TypeState, String>>
Sourcepub fn changed_accounts(&self) -> impl Iterator<Item = &String>
pub fn changed_accounts(&self) -> impl Iterator<Item = &String>
Examples found in repository?
examples/eventsource.rs (line 52)
22async fn event_source() {
23 // Connect to the JMAP server using Basic authentication
24 let client = Client::new()
25 .credentials(("john@example.org", "secret"))
26 .connect("https://jmap.example.org")
27 .await
28 .unwrap();
29
30 // Open EventSource connection
31 let mut stream = client
32 .event_source(
33 [
34 TypeState::Email,
35 TypeState::EmailDelivery,
36 TypeState::Mailbox,
37 TypeState::EmailSubmission,
38 TypeState::Identity,
39 ]
40 .into(),
41 false,
42 60.into(),
43 None,
44 )
45 .await
46 .unwrap();
47
48 // Consume events
49 while let Some(event) = stream.next().await {
50 let changes = event.unwrap();
51 println!("-> Change id: {:?}", changes.id());
52 for account_id in changes.changed_accounts() {
53 println!(" Account {} has changes:", account_id);
54 if let Some(account_changes) = changes.changes(account_id) {
55 for (type_state, state_id) in account_changes {
56 println!(" Type {:?} has a new state {}.", type_state, state_id);
57 }
58 }
59 }
60 }
61}
Sourcepub fn changes(
&self,
account_id: &str,
) -> Option<impl Iterator<Item = (&TypeState, &String)>>
pub fn changes( &self, account_id: &str, ) -> Option<impl Iterator<Item = (&TypeState, &String)>>
Examples found in repository?
examples/eventsource.rs (line 54)
22async fn event_source() {
23 // Connect to the JMAP server using Basic authentication
24 let client = Client::new()
25 .credentials(("john@example.org", "secret"))
26 .connect("https://jmap.example.org")
27 .await
28 .unwrap();
29
30 // Open EventSource connection
31 let mut stream = client
32 .event_source(
33 [
34 TypeState::Email,
35 TypeState::EmailDelivery,
36 TypeState::Mailbox,
37 TypeState::EmailSubmission,
38 TypeState::Identity,
39 ]
40 .into(),
41 false,
42 60.into(),
43 None,
44 )
45 .await
46 .unwrap();
47
48 // Consume events
49 while let Some(event) = stream.next().await {
50 let changes = event.unwrap();
51 println!("-> Change id: {:?}", changes.id());
52 for account_id in changes.changed_accounts() {
53 println!(" Account {} has changes:", account_id);
54 if let Some(account_changes) = changes.changes(account_id) {
55 for (type_state, state_id) in account_changes {
56 println!(" Type {:?} has a new state {}.", type_state, state_id);
57 }
58 }
59 }
60 }
61}
pub fn has_type(&self, type_: TypeState) -> bool
pub fn into_inner(self) -> AHashMap<String, AHashMap<TypeState, String>>
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Changes
impl<'de> Deserialize<'de> for Changes
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Changes
impl StructuralPartialEq for Changes
Auto Trait Implementations§
impl Freeze for Changes
impl RefUnwindSafe for Changes
impl Send for Changes
impl Sync for Changes
impl Unpin for Changes
impl UnwindSafe for Changes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.