Struct Mailbox

Source
pub struct Mailbox<State = Get> { /* private fields */ }

Implementations§

Source§

impl Mailbox<Get>

Source

pub fn id(&self) -> Option<&str>

Source

pub fn take_id(&mut self) -> String

Examples found in repository?
examples/mailboxes.rs (line 36)
23async fn mailboxes() {
24    // Connect to the JMAP server using Basic authentication
25    let client = Client::new()
26        .credentials(("john@example.org", "secret"))
27        .connect("https://jmap.example.org")
28        .await
29        .unwrap();
30
31    // Create a mailbox
32    let mailbox_id = client
33        .mailbox_create("My Mailbox", None::<String>, Role::None)
34        .await
35        .unwrap()
36        .take_id();
37
38    // Rename a mailbox
39    client
40        .mailbox_rename(&mailbox_id, "My Renamed Mailbox")
41        .await
42        .unwrap();
43
44    // Query mailboxes to obtain Inbox's id
45    let inbox_id = client
46        .mailbox_query(Filter::role(Role::Inbox).into(), None::<Vec<_>>)
47        .await
48        .unwrap()
49        .take_ids()
50        .pop()
51        .unwrap();
52
53    // Print Inbox's details
54    println!(
55        "{:?}",
56        client.mailbox_get(&inbox_id, None::<Vec<_>>).await.unwrap()
57    );
58
59    // Move the newly created mailbox under Inbox
60    client
61        .mailbox_move(&mailbox_id, inbox_id.into())
62        .await
63        .unwrap();
64
65    // Delete the mailbox including any messages
66    client.mailbox_destroy(&mailbox_id, true).await.unwrap();
67}
More examples
Hide additional examples
examples/websocket.rs (line 65)
25async fn websocket() {
26    // Connect to the JMAP server using Basic authentication
27    let client = Client::new()
28        .credentials(("john@example.org", "secret"))
29        .connect("https://jmap.example.org")
30        .await
31        .unwrap();
32
33    // Connect to the WebSocket endpoint
34    let mut ws_stream = client.connect_ws().await.unwrap();
35
36    // Read WS messages on a separate thread
37    let (stream_tx, mut stream_rx) = mpsc::channel::<WebSocketMessage>(100);
38    tokio::spawn(async move {
39        while let Some(change) = ws_stream.next().await {
40            stream_tx.send(change.unwrap()).await.unwrap();
41        }
42    });
43
44    // Create a mailbox over WS
45    let mut request = client.build();
46    let create_id = request
47        .set_mailbox()
48        .create()
49        .name("WebSocket Test")
50        .create_id()
51        .unwrap();
52    let request_id = request.send_ws().await.unwrap();
53
54    // Read response from WS stream
55    let mailbox_id = if let Some(WebSocketMessage::Response(mut response)) = stream_rx.recv().await
56    {
57        assert_eq!(request_id, response.request_id().unwrap());
58        response
59            .pop_method_response()
60            .unwrap()
61            .unwrap_set_mailbox()
62            .unwrap()
63            .created(&create_id)
64            .unwrap()
65            .take_id()
66    } else {
67        unreachable!()
68    };
69
70    // Enable push notifications over WS
71    client
72        .enable_push_ws(None::<Vec<_>>, None::<&str>)
73        .await
74        .unwrap();
75
76    // Make changes over standard HTTP and expect a push notification via WS
77    client
78        .mailbox_update_sort_order(&mailbox_id, 1)
79        .await
80        .unwrap();
81    if let Some(WebSocketMessage::StateChange(changes)) = stream_rx.recv().await {
82        println!("Received changes: {:?}", changes);
83    } else {
84        unreachable!()
85    }
86}
Source

pub fn name(&self) -> Option<&str>

Source

pub fn parent_id(&self) -> Option<&str>

Source

pub fn role(&self) -> Role

Source

pub fn sort_order(&self) -> u32

Source

pub fn total_emails(&self) -> usize

Source

pub fn unread_emails(&self) -> usize

Source

pub fn total_threads(&self) -> usize

Source

pub fn unread_threads(&self) -> usize

Source

pub fn is_subscribed(&self) -> bool

Source

pub fn my_rights(&self) -> Option<&MailboxRights>

Source

pub fn acl(&self) -> Option<&AHashMap<String, Vec<ACL>>>

Source

pub fn take_acl(&mut self) -> Option<AHashMap<String, Vec<ACL>>>

Source§

impl Mailbox<Set>

Source

pub fn name(&mut self, name: impl Into<String>) -> &mut Self

Examples found in repository?
examples/websocket.rs (line 49)
25async fn websocket() {
26    // Connect to the JMAP server using Basic authentication
27    let client = Client::new()
28        .credentials(("john@example.org", "secret"))
29        .connect("https://jmap.example.org")
30        .await
31        .unwrap();
32
33    // Connect to the WebSocket endpoint
34    let mut ws_stream = client.connect_ws().await.unwrap();
35
36    // Read WS messages on a separate thread
37    let (stream_tx, mut stream_rx) = mpsc::channel::<WebSocketMessage>(100);
38    tokio::spawn(async move {
39        while let Some(change) = ws_stream.next().await {
40            stream_tx.send(change.unwrap()).await.unwrap();
41        }
42    });
43
44    // Create a mailbox over WS
45    let mut request = client.build();
46    let create_id = request
47        .set_mailbox()
48        .create()
49        .name("WebSocket Test")
50        .create_id()
51        .unwrap();
52    let request_id = request.send_ws().await.unwrap();
53
54    // Read response from WS stream
55    let mailbox_id = if let Some(WebSocketMessage::Response(mut response)) = stream_rx.recv().await
56    {
57        assert_eq!(request_id, response.request_id().unwrap());
58        response
59            .pop_method_response()
60            .unwrap()
61            .unwrap_set_mailbox()
62            .unwrap()
63            .created(&create_id)
64            .unwrap()
65            .take_id()
66    } else {
67        unreachable!()
68    };
69
70    // Enable push notifications over WS
71    client
72        .enable_push_ws(None::<Vec<_>>, None::<&str>)
73        .await
74        .unwrap();
75
76    // Make changes over standard HTTP and expect a push notification via WS
77    client
78        .mailbox_update_sort_order(&mailbox_id, 1)
79        .await
80        .unwrap();
81    if let Some(WebSocketMessage::StateChange(changes)) = stream_rx.recv().await {
82        println!("Received changes: {:?}", changes);
83    } else {
84        unreachable!()
85    }
86}
Source

pub fn parent_id(&mut self, parent_id: Option<impl Into<String>>) -> &mut Self

Source

pub fn parent_id_ref(&mut self, parent_id_ref: &str) -> &mut Self

Source

pub fn role(&mut self, role: Role) -> &mut Self

Source

pub fn sort_order(&mut self, sort_order: u32) -> &mut Self

Source

pub fn is_subscribed(&mut self, is_subscribed: bool) -> &mut Self

Source

pub fn acls<T, U, V>(&mut self, acls: T) -> &mut Self
where T: IntoIterator<Item = (U, V)>, U: Into<String>, V: IntoIterator<Item = ACL>,

Source

pub fn acl(&mut self, id: &str, acl: impl IntoIterator<Item = ACL>) -> &mut Self

Source

pub fn acl_set(&mut self, id: &str, acl: ACL, set: bool) -> &mut Self

Trait Implementations§

Source§

impl ChangesObject for Mailbox<Get>

Source§

impl ChangesObject for Mailbox<Set>

Source§

impl<State: Clone> Clone for Mailbox<State>

Source§

fn clone(&self) -> Mailbox<State>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<State: Debug> Debug for Mailbox<State>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, State> Deserialize<'de> for Mailbox<State>

Source§

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 GetObject for Mailbox<Get>

Source§

impl GetObject for Mailbox<Set>

Source§

impl Object for Mailbox<Get>

Source§

impl Object for Mailbox<Set>

Source§

impl QueryObject for Mailbox<Set>

Source§

impl<State> Serialize for Mailbox<State>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SetObject for Mailbox<Get>

Source§

impl SetObject for Mailbox<Set>

Auto Trait Implementations§

§

impl<State> Freeze for Mailbox<State>

§

impl<State> RefUnwindSafe for Mailbox<State>
where State: RefUnwindSafe,

§

impl<State> Send for Mailbox<State>
where State: Send,

§

impl<State> Sync for Mailbox<State>
where State: Sync,

§

impl<State> Unpin for Mailbox<State>
where State: Unpin,

§

impl<State> UnwindSafe for Mailbox<State>
where State: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T