Struct jmap_client::event_source::Changes
source · 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)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
async fn event_source() {
// Connect to the JMAP server using Basic authentication
let client = Client::new()
.credentials(("john@example.org", "secret"))
.connect("https://jmap.example.org")
.await
.unwrap();
// Open EventSource connection
let mut stream = client
.event_source(
[
TypeState::Email,
TypeState::EmailDelivery,
TypeState::Mailbox,
TypeState::EmailSubmission,
TypeState::Identity,
]
.into(),
false,
60.into(),
None,
)
.await
.unwrap();
// Consume events
while let Some(event) = stream.next().await {
let changes = event.unwrap();
println!("-> Change id: {:?}", changes.id());
for account_id in changes.changed_accounts() {
println!(" Account {} has changes:", account_id);
if let Some(account_changes) = changes.changes(account_id) {
for (type_state, state_id) in account_changes {
println!(" Type {:?} has a new state {}.", type_state, state_id);
}
}
}
}
}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)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
async fn event_source() {
// Connect to the JMAP server using Basic authentication
let client = Client::new()
.credentials(("john@example.org", "secret"))
.connect("https://jmap.example.org")
.await
.unwrap();
// Open EventSource connection
let mut stream = client
.event_source(
[
TypeState::Email,
TypeState::EmailDelivery,
TypeState::Mailbox,
TypeState::EmailSubmission,
TypeState::Identity,
]
.into(),
false,
60.into(),
None,
)
.await
.unwrap();
// Consume events
while let Some(event) = stream.next().await {
let changes = event.unwrap();
println!("-> Change id: {:?}", changes.id());
for account_id in changes.changed_accounts() {
println!(" Account {} has changes:", account_id);
if let Some(account_changes) = changes.changes(account_id) {
for (type_state, state_id) in account_changes {
println!(" Type {:?} has a new state {}.", type_state, state_id);
}
}
}
}
}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)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
async fn event_source() {
// Connect to the JMAP server using Basic authentication
let client = Client::new()
.credentials(("john@example.org", "secret"))
.connect("https://jmap.example.org")
.await
.unwrap();
// Open EventSource connection
let mut stream = client
.event_source(
[
TypeState::Email,
TypeState::EmailDelivery,
TypeState::Mailbox,
TypeState::EmailSubmission,
TypeState::Identity,
]
.into(),
false,
60.into(),
None,
)
.await
.unwrap();
// Consume events
while let Some(event) = stream.next().await {
let changes = event.unwrap();
println!("-> Change id: {:?}", changes.id());
for account_id in changes.changed_accounts() {
println!(" Account {} has changes:", account_id);
if let Some(account_changes) = changes.changes(account_id) {
for (type_state, state_id) in account_changes {
println!(" Type {:?} has a new state {}.", type_state, state_id);
}
}
}
}
}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
source§impl PartialEq for Changes
impl PartialEq for Changes
impl Eq for Changes
impl StructuralEq for Changes
impl StructuralPartialEq for Changes
Auto Trait Implementations§
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<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.