WebSockets implementation.
parent
93802339c2
commit
493f979121
|
@ -202,36 +202,11 @@ impl Client {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::email::EmailBodyPart;
|
use crate::core::response::{Response, TaggedMethodResponse};
|
||||||
|
|
||||||
//#[test]
|
#[test]
|
||||||
fn _test_serialize() {
|
fn test_deserialize() {
|
||||||
println!(
|
let _r: Response<TaggedMethodResponse> = serde_json::from_slice(
|
||||||
"{:?}",
|
|
||||||
serde_json::from_slice::<EmailBodyPart>(
|
|
||||||
br#"{
|
|
||||||
"partId": "0",
|
|
||||||
"header:X-Custom-Header": "123",
|
|
||||||
"type": "text/html",
|
|
||||||
"charset": "us-ascii",
|
|
||||||
"size": 175
|
|
||||||
}"#
|
|
||||||
)
|
|
||||||
.unwrap()
|
|
||||||
);
|
|
||||||
|
|
||||||
/*let coco = request
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.unwrap_method_responses()
|
|
||||||
.pop()
|
|
||||||
.unwrap()
|
|
||||||
.unwrap_get_email()
|
|
||||||
.unwrap();*/
|
|
||||||
//coco.list().first().unwrap().subject().unwrap();
|
|
||||||
|
|
||||||
/*let r: Response = serde_json::from_slice(
|
|
||||||
br#"{"sessionState": "123", "methodResponses": [[ "Email/query", {
|
br#"{"sessionState": "123", "methodResponses": [[ "Email/query", {
|
||||||
"accountId": "A1",
|
"accountId": "A1",
|
||||||
"queryState": "abcdefg",
|
"queryState": "abcdefg",
|
||||||
|
@ -268,50 +243,8 @@ mod tests {
|
||||||
"notFound": []
|
"notFound": []
|
||||||
}, "t2" ]]}"#,
|
}, "t2" ]]}"#,
|
||||||
)
|
)
|
||||||
.unwrap();*/
|
.unwrap();
|
||||||
|
|
||||||
//println!("{:?}", r);
|
//println!("{:?}", r);
|
||||||
|
|
||||||
/*let mut client = Client::connect("coco");
|
|
||||||
let mut request = client.request();
|
|
||||||
|
|
||||||
let set = request.set_email();
|
|
||||||
set.create().from(["pepe"]).subject("coco");
|
|
||||||
set.update("id").keyword("keyword", true);
|
|
||||||
set.destroy(["1", "2"]);
|
|
||||||
|
|
||||||
let ref_ = request.result_reference("/pepe/1");
|
|
||||||
|
|
||||||
let get = request.get_email();
|
|
||||||
get.ids_ref(ref_);
|
|
||||||
|
|
||||||
println!("{}", serde_json::to_string_pretty(&request).unwrap());*/
|
|
||||||
|
|
||||||
/*let mut client = Client::connect("coco");
|
|
||||||
|
|
||||||
client.request().email_set().create(
|
|
||||||
"coco",
|
|
||||||
Email::new()
|
|
||||||
.from(["Pepe"])
|
|
||||||
.subject("Hello world!")
|
|
||||||
.sent_at(342374),
|
|
||||||
);*/
|
|
||||||
|
|
||||||
/*let query: QueryRequest<EmailFilter, EmailComparator, email::QueryArguments> =
|
|
||||||
QueryRequest::new("coco".to_string())
|
|
||||||
.filter(Filter::or([
|
|
||||||
Filter::and([
|
|
||||||
EmailFilter::in_mailbox("peperino"),
|
|
||||||
EmailFilter::in_mailbox_other_than(["coco", "miel"]),
|
|
||||||
EmailFilter::from("comoro"),
|
|
||||||
]),
|
|
||||||
Filter::not([EmailFilter::after(428374234)]),
|
|
||||||
]))
|
|
||||||
.sort([
|
|
||||||
EmailComparator::has_keyword("cocomiel"),
|
|
||||||
EmailComparator::size(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
println!("{}", serde_json::to_string_pretty(&query).unwrap());*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ use super::{
|
||||||
get::GetRequest,
|
get::GetRequest,
|
||||||
query::QueryRequest,
|
query::QueryRequest,
|
||||||
query_changes::QueryChangesRequest,
|
query_changes::QueryChangesRequest,
|
||||||
response::{MethodResponse, Response, SingleMethodResponse},
|
response::{Response, SingleMethodResponse, TaggedMethodResponse},
|
||||||
set::SetRequest,
|
set::SetRequest,
|
||||||
RequestParams,
|
RequestParams,
|
||||||
};
|
};
|
||||||
|
@ -412,7 +412,7 @@ impl<'x> Request<'x> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send(mut self) -> crate::Result<Response<MethodResponse>> {
|
pub async fn send(mut self) -> crate::Result<Response<TaggedMethodResponse>> {
|
||||||
Option::take(&mut self.client).unwrap().send(&self).await
|
Option::take(&mut self.client).unwrap().send(&self).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::{collections::HashMap, fmt};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{de::Visitor, Deserialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
blob::copy::CopyBlobResponse,
|
blob::copy::CopyBlobResponse,
|
||||||
|
@ -19,7 +19,7 @@ use super::{
|
||||||
query::QueryResponse, query_changes::QueryChangesResponse, set::SetResponse,
|
query::QueryResponse, query_changes::QueryChangesResponse, set::SetResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Response<T> {
|
pub struct Response<T> {
|
||||||
#[serde(rename = "methodResponses")]
|
#[serde(rename = "methodResponses")]
|
||||||
method_responses: Vec<T>,
|
method_responses: Vec<T>,
|
||||||
|
@ -73,8 +73,8 @@ impl<T> Response<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Response<MethodResponse> {
|
impl Response<TaggedMethodResponse> {
|
||||||
pub fn method_response(&self, id: &str) -> Option<&MethodResponse> {
|
pub fn method_response(&self, id: &str) -> Option<&TaggedMethodResponse> {
|
||||||
self.method_responses
|
self.method_responses
|
||||||
.iter()
|
.iter()
|
||||||
.find(|response| response.call_id() == id)
|
.find(|response| response.call_id() == id)
|
||||||
|
@ -88,6 +88,11 @@ pub enum SingleMethodResponse<T> {
|
||||||
Ok((String, T, String)),
|
Ok((String, T, String)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub enum Error {
|
||||||
|
Error,
|
||||||
|
}
|
||||||
|
|
||||||
pub type PushSubscriptionSetResponse =
|
pub type PushSubscriptionSetResponse =
|
||||||
SetResponse<PushSubscription<Get>, push_subscription::Property>;
|
SetResponse<PushSubscription<Get>, push_subscription::Property>;
|
||||||
pub type PushSubscriptionGetResponse = GetResponse<PushSubscription<Get>>;
|
pub type PushSubscriptionGetResponse = GetResponse<PushSubscription<Get>>;
|
||||||
|
@ -111,555 +116,526 @@ pub type VacationResponseGetResponse = GetResponse<VacationResponse<Get>>;
|
||||||
pub type VacationResponseSetResponse =
|
pub type VacationResponseSetResponse =
|
||||||
SetResponse<VacationResponse<Get>, vacation_response::Property>;
|
SetResponse<VacationResponse<Get>, vacation_response::Property>;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug)]
|
||||||
#[serde(untagged)]
|
pub struct TaggedMethodResponse {
|
||||||
pub enum MethodResponse {
|
id: String,
|
||||||
CopyBlob((CopyBlob, CopyBlobResponse, String)),
|
response: MethodResponse,
|
||||||
GetPushSubscription((GetPushSubscription, PushSubscriptionGetResponse, String)),
|
|
||||||
SetPushSubscription((SetPushSubscription, PushSubscriptionSetResponse, String)),
|
|
||||||
GetMailbox((GetMailbox, MailboxGetResponse, String)),
|
|
||||||
ChangesMailbox((ChangesMailbox, MaiboxChangesResponse, String)),
|
|
||||||
QueryMailbox((QueryMailbox, QueryResponse, String)),
|
|
||||||
QueryChangesMailbox((QueryChangesMailbox, QueryChangesResponse, String)),
|
|
||||||
SetMailbox((SetMailbox, MailboxSetResponse, String)),
|
|
||||||
GetThread((GetThread, ThreadGetResponse, String)),
|
|
||||||
ChangesThread((ChangesThread, ThreadChangesResponse, String)),
|
|
||||||
GetEmail((GetEmail, EmailGetResponse, String)),
|
|
||||||
ChangesEmail((ChangesEmail, EmailChangesResponse, String)),
|
|
||||||
QueryEmail((QueryEmail, QueryResponse, String)),
|
|
||||||
QueryChangesEmail((QueryChangesEmail, QueryChangesResponse, String)),
|
|
||||||
SetEmail((SetEmail, EmailSetResponse, String)),
|
|
||||||
CopyEmail((CopyEmail, EmailCopyResponse, String)),
|
|
||||||
ImportEmail((ImportEmail, EmailImportResponse, String)),
|
|
||||||
ParseEmail((ParseEmail, EmailParseResponse, String)),
|
|
||||||
GetSearchSnippet((GetSearchSnippet, SearchSnippetGetResponse, String)),
|
|
||||||
GetIdentity((GetIdentity, IdentityGetResponse, String)),
|
|
||||||
ChangesIdentity((ChangesIdentity, IdentityChangesResponse, String)),
|
|
||||||
SetIdentity((SetIdentity, IdentitySetResponse, String)),
|
|
||||||
GetEmailSubmission((GetEmailSubmission, EmailSubmissionGetResponse, String)),
|
|
||||||
ChangesEmailSubmission(
|
|
||||||
(
|
|
||||||
ChangesEmailSubmission,
|
|
||||||
EmailSubmissionChangesResponse,
|
|
||||||
String,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
QueryEmailSubmission((QueryEmailSubmission, QueryResponse, String)),
|
|
||||||
QueryChangesEmailSubmission((QueryChangesEmailSubmission, QueryChangesResponse, String)),
|
|
||||||
SetEmailSubmission((SetEmailSubmission, EmailSubmissionSetResponse, String)),
|
|
||||||
GetVacationResponse((GetVacationResponse, VacationResponseGetResponse, String)),
|
|
||||||
SetVacationResponse((SetVacationResponse, VacationResponseSetResponse, String)),
|
|
||||||
Echo((Echo, serde_json::Value, String)),
|
|
||||||
Error((Error, MethodError, String)),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MethodResponse {
|
#[derive(Debug)]
|
||||||
|
pub enum MethodResponse {
|
||||||
|
CopyBlob(CopyBlobResponse),
|
||||||
|
GetPushSubscription(PushSubscriptionGetResponse),
|
||||||
|
SetPushSubscription(PushSubscriptionSetResponse),
|
||||||
|
GetMailbox(MailboxGetResponse),
|
||||||
|
ChangesMailbox(MaiboxChangesResponse),
|
||||||
|
QueryMailbox(QueryResponse),
|
||||||
|
QueryChangesMailbox(QueryChangesResponse),
|
||||||
|
SetMailbox(MailboxSetResponse),
|
||||||
|
GetThread(ThreadGetResponse),
|
||||||
|
ChangesThread(ThreadChangesResponse),
|
||||||
|
GetEmail(EmailGetResponse),
|
||||||
|
ChangesEmail(EmailChangesResponse),
|
||||||
|
QueryEmail(QueryResponse),
|
||||||
|
QueryChangesEmail(QueryChangesResponse),
|
||||||
|
SetEmail(EmailSetResponse),
|
||||||
|
CopyEmail(EmailCopyResponse),
|
||||||
|
ImportEmail(EmailImportResponse),
|
||||||
|
ParseEmail(EmailParseResponse),
|
||||||
|
GetSearchSnippet(SearchSnippetGetResponse),
|
||||||
|
GetIdentity(IdentityGetResponse),
|
||||||
|
ChangesIdentity(IdentityChangesResponse),
|
||||||
|
SetIdentity(IdentitySetResponse),
|
||||||
|
GetEmailSubmission(EmailSubmissionGetResponse),
|
||||||
|
ChangesEmailSubmission(EmailSubmissionChangesResponse),
|
||||||
|
QueryEmailSubmission(QueryResponse),
|
||||||
|
QueryChangesEmailSubmission(QueryChangesResponse),
|
||||||
|
SetEmailSubmission(EmailSubmissionSetResponse),
|
||||||
|
GetVacationResponse(VacationResponseGetResponse),
|
||||||
|
SetVacationResponse(VacationResponseSetResponse),
|
||||||
|
Echo(serde_json::Value),
|
||||||
|
Error(MethodError),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TaggedMethodResponse {
|
||||||
pub fn call_id(&self) -> &str {
|
pub fn call_id(&self) -> &str {
|
||||||
match self {
|
self.id.as_str()
|
||||||
Self::CopyBlob((_, _, id)) => id,
|
|
||||||
Self::GetPushSubscription((_, _, id)) => id,
|
|
||||||
Self::SetPushSubscription((_, _, id)) => id,
|
|
||||||
Self::GetMailbox((_, _, id)) => id,
|
|
||||||
Self::ChangesMailbox((_, _, id)) => id,
|
|
||||||
Self::QueryMailbox((_, _, id)) => id,
|
|
||||||
Self::QueryChangesMailbox((_, _, id)) => id,
|
|
||||||
Self::SetMailbox((_, _, id)) => id,
|
|
||||||
Self::GetThread((_, _, id)) => id,
|
|
||||||
Self::ChangesThread((_, _, id)) => id,
|
|
||||||
Self::GetEmail((_, _, id)) => id,
|
|
||||||
Self::ChangesEmail((_, _, id)) => id,
|
|
||||||
Self::QueryEmail((_, _, id)) => id,
|
|
||||||
Self::QueryChangesEmail((_, _, id)) => id,
|
|
||||||
Self::SetEmail((_, _, id)) => id,
|
|
||||||
Self::CopyEmail((_, _, id)) => id,
|
|
||||||
Self::ImportEmail((_, _, id)) => id,
|
|
||||||
Self::ParseEmail((_, _, id)) => id,
|
|
||||||
Self::GetSearchSnippet((_, _, id)) => id,
|
|
||||||
Self::GetIdentity((_, _, id)) => id,
|
|
||||||
Self::ChangesIdentity((_, _, id)) => id,
|
|
||||||
Self::SetIdentity((_, _, id)) => id,
|
|
||||||
Self::GetEmailSubmission((_, _, id)) => id,
|
|
||||||
Self::ChangesEmailSubmission((_, _, id)) => id,
|
|
||||||
Self::QueryEmailSubmission((_, _, id)) => id,
|
|
||||||
Self::QueryChangesEmailSubmission((_, _, id)) => id,
|
|
||||||
Self::SetEmailSubmission((_, _, id)) => id,
|
|
||||||
Self::GetVacationResponse((_, _, id)) => id,
|
|
||||||
Self::SetVacationResponse((_, _, id)) => id,
|
|
||||||
Self::Echo((_, _, id)) => id,
|
|
||||||
Self::Error((_, _, id)) => id,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_type(&self, type_: Method) -> bool {
|
pub fn is_type(&self, type_: Method) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
(self, type_),
|
(&self.response, type_),
|
||||||
(Self::CopyBlob(_), Method::CopyBlob)
|
(MethodResponse::CopyBlob(_), Method::CopyBlob)
|
||||||
| (Self::GetPushSubscription(_), Method::GetPushSubscription)
|
|
||||||
| (Self::SetPushSubscription(_), Method::SetPushSubscription)
|
|
||||||
| (Self::GetMailbox(_), Method::GetMailbox)
|
|
||||||
| (Self::ChangesMailbox(_), Method::ChangesMailbox)
|
|
||||||
| (Self::QueryMailbox(_), Method::QueryMailbox)
|
|
||||||
| (Self::QueryChangesMailbox(_), Method::QueryChangesMailbox)
|
|
||||||
| (Self::SetMailbox(_), Method::SetMailbox)
|
|
||||||
| (Self::GetThread(_), Method::GetThread)
|
|
||||||
| (Self::ChangesThread(_), Method::ChangesThread)
|
|
||||||
| (Self::GetEmail(_), Method::GetEmail)
|
|
||||||
| (Self::ChangesEmail(_), Method::ChangesEmail)
|
|
||||||
| (Self::QueryEmail(_), Method::QueryEmail)
|
|
||||||
| (Self::QueryChangesEmail(_), Method::QueryChangesEmail)
|
|
||||||
| (Self::SetEmail(_), Method::SetEmail)
|
|
||||||
| (Self::CopyEmail(_), Method::CopyEmail)
|
|
||||||
| (Self::ImportEmail(_), Method::ImportEmail)
|
|
||||||
| (Self::ParseEmail(_), Method::ParseEmail)
|
|
||||||
| (Self::GetSearchSnippet(_), Method::GetSearchSnippet)
|
|
||||||
| (Self::GetIdentity(_), Method::GetIdentity)
|
|
||||||
| (Self::ChangesIdentity(_), Method::ChangesIdentity)
|
|
||||||
| (Self::SetIdentity(_), Method::SetIdentity)
|
|
||||||
| (Self::GetEmailSubmission(_), Method::GetEmailSubmission)
|
|
||||||
| (
|
| (
|
||||||
Self::ChangesEmailSubmission(_),
|
MethodResponse::GetPushSubscription(_),
|
||||||
|
Method::GetPushSubscription
|
||||||
|
)
|
||||||
|
| (
|
||||||
|
MethodResponse::SetPushSubscription(_),
|
||||||
|
Method::SetPushSubscription
|
||||||
|
)
|
||||||
|
| (MethodResponse::GetMailbox(_), Method::GetMailbox)
|
||||||
|
| (MethodResponse::ChangesMailbox(_), Method::ChangesMailbox)
|
||||||
|
| (MethodResponse::QueryMailbox(_), Method::QueryMailbox)
|
||||||
|
| (
|
||||||
|
MethodResponse::QueryChangesMailbox(_),
|
||||||
|
Method::QueryChangesMailbox
|
||||||
|
)
|
||||||
|
| (MethodResponse::SetMailbox(_), Method::SetMailbox)
|
||||||
|
| (MethodResponse::GetThread(_), Method::GetThread)
|
||||||
|
| (MethodResponse::ChangesThread(_), Method::ChangesThread)
|
||||||
|
| (MethodResponse::GetEmail(_), Method::GetEmail)
|
||||||
|
| (MethodResponse::ChangesEmail(_), Method::ChangesEmail)
|
||||||
|
| (MethodResponse::QueryEmail(_), Method::QueryEmail)
|
||||||
|
| (
|
||||||
|
MethodResponse::QueryChangesEmail(_),
|
||||||
|
Method::QueryChangesEmail
|
||||||
|
)
|
||||||
|
| (MethodResponse::SetEmail(_), Method::SetEmail)
|
||||||
|
| (MethodResponse::CopyEmail(_), Method::CopyEmail)
|
||||||
|
| (MethodResponse::ImportEmail(_), Method::ImportEmail)
|
||||||
|
| (MethodResponse::ParseEmail(_), Method::ParseEmail)
|
||||||
|
| (
|
||||||
|
MethodResponse::GetSearchSnippet(_),
|
||||||
|
Method::GetSearchSnippet
|
||||||
|
)
|
||||||
|
| (MethodResponse::GetIdentity(_), Method::GetIdentity)
|
||||||
|
| (MethodResponse::ChangesIdentity(_), Method::ChangesIdentity)
|
||||||
|
| (MethodResponse::SetIdentity(_), Method::SetIdentity)
|
||||||
|
| (
|
||||||
|
MethodResponse::GetEmailSubmission(_),
|
||||||
|
Method::GetEmailSubmission
|
||||||
|
)
|
||||||
|
| (
|
||||||
|
MethodResponse::ChangesEmailSubmission(_),
|
||||||
Method::ChangesEmailSubmission
|
Method::ChangesEmailSubmission
|
||||||
)
|
)
|
||||||
| (Self::QueryEmailSubmission(_), Method::QueryEmailSubmission)
|
|
||||||
| (
|
| (
|
||||||
Self::QueryChangesEmailSubmission(_),
|
MethodResponse::QueryEmailSubmission(_),
|
||||||
|
Method::QueryEmailSubmission
|
||||||
|
)
|
||||||
|
| (
|
||||||
|
MethodResponse::QueryChangesEmailSubmission(_),
|
||||||
Method::QueryChangesEmailSubmission
|
Method::QueryChangesEmailSubmission
|
||||||
)
|
)
|
||||||
| (Self::SetEmailSubmission(_), Method::SetEmailSubmission)
|
| (
|
||||||
| (Self::GetVacationResponse(_), Method::GetVacationResponse)
|
MethodResponse::SetEmailSubmission(_),
|
||||||
| (Self::SetVacationResponse(_), Method::SetVacationResponse)
|
Method::SetEmailSubmission
|
||||||
| (Self::Echo(_), Method::Echo)
|
)
|
||||||
| (Self::Error(_), Method::Error)
|
| (
|
||||||
|
MethodResponse::GetVacationResponse(_),
|
||||||
|
Method::GetVacationResponse
|
||||||
|
)
|
||||||
|
| (
|
||||||
|
MethodResponse::SetVacationResponse(_),
|
||||||
|
Method::SetVacationResponse
|
||||||
|
)
|
||||||
|
| (MethodResponse::Echo(_), Method::Echo)
|
||||||
|
| (MethodResponse::Error(_), Method::Error)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_copy_blob(self) -> crate::Result<CopyBlobResponse> {
|
pub fn unwrap_copy_blob(self) -> crate::Result<CopyBlobResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::CopyBlob((_, response, _)) => Ok(response),
|
MethodResponse::CopyBlob(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_get_push_subscription(self) -> crate::Result<PushSubscriptionGetResponse> {
|
pub fn unwrap_get_push_subscription(self) -> crate::Result<PushSubscriptionGetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::GetPushSubscription((_, response, _)) => Ok(response),
|
MethodResponse::GetPushSubscription(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_set_push_subscription(self) -> crate::Result<PushSubscriptionSetResponse> {
|
pub fn unwrap_set_push_subscription(self) -> crate::Result<PushSubscriptionSetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::SetPushSubscription((_, response, _)) => Ok(response),
|
MethodResponse::SetPushSubscription(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_get_mailbox(self) -> crate::Result<MailboxGetResponse> {
|
pub fn unwrap_get_mailbox(self) -> crate::Result<MailboxGetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::GetMailbox((_, response, _)) => Ok(response),
|
MethodResponse::GetMailbox(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_changes_mailbox(self) -> crate::Result<MaiboxChangesResponse> {
|
pub fn unwrap_changes_mailbox(self) -> crate::Result<MaiboxChangesResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::ChangesMailbox((_, response, _)) => Ok(response),
|
MethodResponse::ChangesMailbox(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_query_mailbox(self) -> crate::Result<QueryResponse> {
|
pub fn unwrap_query_mailbox(self) -> crate::Result<QueryResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::QueryMailbox((_, response, _)) => Ok(response),
|
MethodResponse::QueryMailbox(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_query_changes_mailbox(self) -> crate::Result<QueryChangesResponse> {
|
pub fn unwrap_query_changes_mailbox(self) -> crate::Result<QueryChangesResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::QueryChangesMailbox((_, response, _)) => Ok(response),
|
MethodResponse::QueryChangesMailbox(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_set_mailbox(self) -> crate::Result<MailboxSetResponse> {
|
pub fn unwrap_set_mailbox(self) -> crate::Result<MailboxSetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::SetMailbox((_, response, _)) => Ok(response),
|
MethodResponse::SetMailbox(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_get_thread(self) -> crate::Result<ThreadGetResponse> {
|
pub fn unwrap_get_thread(self) -> crate::Result<ThreadGetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::GetThread((_, response, _)) => Ok(response),
|
MethodResponse::GetThread(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_changes_thread(self) -> crate::Result<ThreadChangesResponse> {
|
pub fn unwrap_changes_thread(self) -> crate::Result<ThreadChangesResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::ChangesThread((_, response, _)) => Ok(response),
|
MethodResponse::ChangesThread(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_get_email(self) -> crate::Result<EmailGetResponse> {
|
pub fn unwrap_get_email(self) -> crate::Result<EmailGetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::GetEmail((_, response, _)) => Ok(response),
|
MethodResponse::GetEmail(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_changes_email(self) -> crate::Result<EmailChangesResponse> {
|
pub fn unwrap_changes_email(self) -> crate::Result<EmailChangesResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::ChangesEmail((_, response, _)) => Ok(response),
|
MethodResponse::ChangesEmail(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_query_email(self) -> crate::Result<QueryResponse> {
|
pub fn unwrap_query_email(self) -> crate::Result<QueryResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::QueryEmail((_, response, _)) => Ok(response),
|
MethodResponse::QueryEmail(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_query_changes_email(self) -> crate::Result<QueryChangesResponse> {
|
pub fn unwrap_query_changes_email(self) -> crate::Result<QueryChangesResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::QueryChangesEmail((_, response, _)) => Ok(response),
|
MethodResponse::QueryChangesEmail(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_set_email(self) -> crate::Result<EmailSetResponse> {
|
pub fn unwrap_set_email(self) -> crate::Result<EmailSetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::SetEmail((_, response, _)) => Ok(response),
|
MethodResponse::SetEmail(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_copy_email(self) -> crate::Result<EmailCopyResponse> {
|
pub fn unwrap_copy_email(self) -> crate::Result<EmailCopyResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::CopyEmail((_, response, _)) => Ok(response),
|
MethodResponse::CopyEmail(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_import_email(self) -> crate::Result<EmailImportResponse> {
|
pub fn unwrap_import_email(self) -> crate::Result<EmailImportResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::ImportEmail((_, response, _)) => Ok(response),
|
MethodResponse::ImportEmail(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_parse_email(self) -> crate::Result<EmailParseResponse> {
|
pub fn unwrap_parse_email(self) -> crate::Result<EmailParseResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::ParseEmail((_, response, _)) => Ok(response),
|
MethodResponse::ParseEmail(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_get_search_snippet(self) -> crate::Result<SearchSnippetGetResponse> {
|
pub fn unwrap_get_search_snippet(self) -> crate::Result<SearchSnippetGetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::GetSearchSnippet((_, response, _)) => Ok(response),
|
MethodResponse::GetSearchSnippet(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_get_identity(self) -> crate::Result<IdentityGetResponse> {
|
pub fn unwrap_get_identity(self) -> crate::Result<IdentityGetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::GetIdentity((_, response, _)) => Ok(response),
|
MethodResponse::GetIdentity(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_changes_identity(self) -> crate::Result<IdentityChangesResponse> {
|
pub fn unwrap_changes_identity(self) -> crate::Result<IdentityChangesResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::ChangesIdentity((_, response, _)) => Ok(response),
|
MethodResponse::ChangesIdentity(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_set_identity(self) -> crate::Result<IdentitySetResponse> {
|
pub fn unwrap_set_identity(self) -> crate::Result<IdentitySetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::SetIdentity((_, response, _)) => Ok(response),
|
MethodResponse::SetIdentity(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_get_email_submission(self) -> crate::Result<EmailSubmissionGetResponse> {
|
pub fn unwrap_get_email_submission(self) -> crate::Result<EmailSubmissionGetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::GetEmailSubmission((_, response, _)) => Ok(response),
|
MethodResponse::GetEmailSubmission(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_changes_email_submission(self) -> crate::Result<EmailSubmissionChangesResponse> {
|
pub fn unwrap_changes_email_submission(self) -> crate::Result<EmailSubmissionChangesResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::ChangesEmailSubmission((_, response, _)) => Ok(response),
|
MethodResponse::ChangesEmailSubmission(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_set_email_submission(self) -> crate::Result<EmailSubmissionSetResponse> {
|
pub fn unwrap_set_email_submission(self) -> crate::Result<EmailSubmissionSetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::SetEmailSubmission((_, response, _)) => Ok(response),
|
MethodResponse::SetEmailSubmission(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_query_email_submission(self) -> crate::Result<QueryResponse> {
|
pub fn unwrap_query_email_submission(self) -> crate::Result<QueryResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::QueryEmailSubmission((_, response, _)) => Ok(response),
|
MethodResponse::QueryEmailSubmission(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_query_changes_email_submission(self) -> crate::Result<QueryChangesResponse> {
|
pub fn unwrap_query_changes_email_submission(self) -> crate::Result<QueryChangesResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::QueryChangesEmailSubmission((_, response, _)) => Ok(response),
|
MethodResponse::QueryChangesEmailSubmission(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_get_vacation_response(self) -> crate::Result<VacationResponseGetResponse> {
|
pub fn unwrap_get_vacation_response(self) -> crate::Result<VacationResponseGetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::GetVacationResponse((_, response, _)) => Ok(response),
|
MethodResponse::GetVacationResponse(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_set_vacation_response(self) -> crate::Result<VacationResponseSetResponse> {
|
pub fn unwrap_set_vacation_response(self) -> crate::Result<VacationResponseSetResponse> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::SetVacationResponse((_, response, _)) => Ok(response),
|
MethodResponse::SetVacationResponse(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_echo(self) -> crate::Result<serde_json::Value> {
|
pub fn unwrap_echo(self) -> crate::Result<serde_json::Value> {
|
||||||
match self {
|
match self.response {
|
||||||
Self::Echo((_, response, _)) => Ok(response),
|
MethodResponse::Echo(response) => Ok(response),
|
||||||
Self::Error((_, err, _)) => Err(err.into()),
|
MethodResponse::Error(err) => Err(err.into()),
|
||||||
_ => Err("Response type mismatch".into()),
|
_ => Err("Response type mismatch".into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_error(&self) -> bool {
|
pub fn is_error(&self) -> bool {
|
||||||
matches!(self, Self::Error(_))
|
matches!(self.response, MethodResponse::Error(_))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
impl<'de> Deserialize<'de> for TaggedMethodResponse {
|
||||||
pub enum Echo {
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
#[serde(rename = "Core/echo")]
|
where
|
||||||
V,
|
D: serde::Deserializer<'de>,
|
||||||
|
{
|
||||||
|
deserializer.deserialize_seq(TaggedMethodResponseVisitor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
struct TaggedMethodResponseVisitor;
|
||||||
pub enum CopyBlob {
|
|
||||||
#[serde(rename = "Blob/copy")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
impl<'de> Visitor<'de> for TaggedMethodResponseVisitor {
|
||||||
pub enum GetPushSubscription {
|
type Value = TaggedMethodResponse;
|
||||||
#[serde(rename = "PushSubscription/get")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
pub enum SetPushSubscription {
|
formatter.write_str("a valid JMAP method response")
|
||||||
#[serde(rename = "PushSubscription/set")]
|
}
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
|
||||||
pub enum GetMailbox {
|
where
|
||||||
#[serde(rename = "Mailbox/get")]
|
A: serde::de::SeqAccess<'de>,
|
||||||
V,
|
{
|
||||||
}
|
let response = match seq
|
||||||
|
.next_element::<Method>()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method name"))?
|
||||||
|
{
|
||||||
|
Method::Echo => MethodResponse::Echo(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::CopyBlob => MethodResponse::CopyBlob(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::GetPushSubscription => MethodResponse::GetPushSubscription(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::SetPushSubscription => MethodResponse::SetPushSubscription(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::GetMailbox => MethodResponse::GetMailbox(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::ChangesMailbox => MethodResponse::ChangesMailbox(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::QueryMailbox => MethodResponse::QueryMailbox(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::QueryChangesMailbox => MethodResponse::QueryChangesMailbox(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::SetMailbox => MethodResponse::SetMailbox(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::GetThread => MethodResponse::GetThread(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::ChangesThread => MethodResponse::ChangesThread(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::GetEmail => MethodResponse::GetEmail(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::ChangesEmail => MethodResponse::ChangesEmail(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::QueryEmail => MethodResponse::QueryEmail(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::QueryChangesEmail => MethodResponse::QueryChangesEmail(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::SetEmail => MethodResponse::SetEmail(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::CopyEmail => MethodResponse::CopyEmail(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::ImportEmail => MethodResponse::ImportEmail(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::ParseEmail => MethodResponse::ParseEmail(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::GetSearchSnippet => MethodResponse::GetSearchSnippet(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::GetIdentity => MethodResponse::GetIdentity(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::ChangesIdentity => MethodResponse::ChangesIdentity(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::SetIdentity => MethodResponse::SetIdentity(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::GetEmailSubmission => MethodResponse::GetEmailSubmission(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::ChangesEmailSubmission => MethodResponse::ChangesEmailSubmission(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::QueryEmailSubmission => MethodResponse::QueryEmailSubmission(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::QueryChangesEmailSubmission => MethodResponse::QueryChangesEmailSubmission(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::SetEmailSubmission => MethodResponse::SetEmailSubmission(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::GetVacationResponse => MethodResponse::GetVacationResponse(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::SetVacationResponse => MethodResponse::SetVacationResponse(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
Method::Error => MethodResponse::Error(
|
||||||
|
seq.next_element()?
|
||||||
|
.ok_or_else(|| serde::de::Error::custom("Expected a method response"))?,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
let id = seq
|
||||||
pub enum ChangesMailbox {
|
.next_element::<String>()?
|
||||||
#[serde(rename = "Mailbox/changes")]
|
.ok_or_else(|| serde::de::Error::custom("Expected method call id"))?;
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
Ok(TaggedMethodResponse { response, id })
|
||||||
pub enum QueryMailbox {
|
}
|
||||||
#[serde(rename = "Mailbox/query")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum QueryChangesMailbox {
|
|
||||||
#[serde(rename = "Mailbox/queryChanges")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum SetMailbox {
|
|
||||||
#[serde(rename = "Mailbox/set")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum GetThread {
|
|
||||||
#[serde(rename = "Thread/get")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum ChangesThread {
|
|
||||||
#[serde(rename = "Thread/changes")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum GetEmail {
|
|
||||||
#[serde(rename = "Email/get")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum ChangesEmail {
|
|
||||||
#[serde(rename = "Email/changes")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum QueryEmail {
|
|
||||||
#[serde(rename = "Email/query")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum QueryChangesEmail {
|
|
||||||
#[serde(rename = "Email/queryChanges")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum SetEmail {
|
|
||||||
#[serde(rename = "Email/set")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum CopyEmail {
|
|
||||||
#[serde(rename = "Email/copy")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum ImportEmail {
|
|
||||||
#[serde(rename = "Email/import")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum ParseEmail {
|
|
||||||
#[serde(rename = "Email/parse")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum GetSearchSnippet {
|
|
||||||
#[serde(rename = "SearchSnippet/get")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum GetIdentity {
|
|
||||||
#[serde(rename = "Identity/get")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum ChangesIdentity {
|
|
||||||
#[serde(rename = "Identity/changes")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum SetIdentity {
|
|
||||||
#[serde(rename = "Identity/set")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum GetEmailSubmission {
|
|
||||||
#[serde(rename = "EmailSubmission/get")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum ChangesEmailSubmission {
|
|
||||||
#[serde(rename = "EmailSubmission/changes")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum QueryEmailSubmission {
|
|
||||||
#[serde(rename = "EmailSubmission/query")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum QueryChangesEmailSubmission {
|
|
||||||
#[serde(rename = "EmailSubmission/queryChanges")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum SetEmailSubmission {
|
|
||||||
#[serde(rename = "EmailSubmission/set")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum GetVacationResponse {
|
|
||||||
#[serde(rename = "VacationResponse/get")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum SetVacationResponse {
|
|
||||||
#[serde(rename = "VacationResponse/set")]
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub enum Error {
|
|
||||||
#[serde(rename = "error")]
|
|
||||||
V,
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue