From 5d8f07c8058261c7c251b3fb010ad866110e91df Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 28 Aug 2023 13:26:41 +0300 Subject: [PATCH] melib/jmap: rename some objects better Signed-off-by: Manos Pitsidianakis --- melib/src/jmap/mod.rs | 6 +++--- melib/src/jmap/objects/email/import.rs | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/melib/src/jmap/mod.rs b/melib/src/jmap/mod.rs index 19f91365..bcb06bfe 100644 --- a/melib/src/jmap/mod.rs +++ b/melib/src/jmap/mod.rs @@ -471,7 +471,7 @@ impl MailBackend for JmapType { let mut req = Request::new(conn.request_no.clone()); let creation_id: Id = "1".to_string().into(); - let import_call: ImportCall = ImportCall::new() + let import_call: EmailImport = EmailImport::new() .account_id(conn.mail_account_id()) .emails(indexmap! { creation_id.clone() => EmailImportObject::new() @@ -492,8 +492,8 @@ impl MailBackend for JmapType { } Ok(s) => s, }; - let m = ImportResponse::try_from(v.method_responses.remove(0)).map_err(|err| { - let ierr: Result = deserialize_from_str(&res_text); + let m = EmailImportResponse::try_from(v.method_responses.remove(0)).map_err(|err| { + let ierr: Result = deserialize_from_str(&res_text); if let Ok(err) = ierr { Error::new(format!("Could not save message: {:?}", err)) } else { diff --git a/melib/src/jmap/objects/email/import.rs b/melib/src/jmap/objects/email/import.rs index a540a385..eae9daec 100644 --- a/melib/src/jmap/objects/email/import.rs +++ b/melib/src/jmap/objects/email/import.rs @@ -35,7 +35,7 @@ use super::*; /// The id of the account to use. #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] -pub struct ImportCall { +pub struct EmailImport { /// accountId: `Id` /// The id of the account to use. pub account_id: Id, @@ -72,7 +72,7 @@ pub struct EmailImportObject { pub received_at: Option, } -impl ImportCall { +impl EmailImport { pub fn new() -> Self { Self { account_id: Id::empty(), @@ -91,13 +91,13 @@ impl ImportCall { _impl!(emails: IndexMap, EmailImportObject>); } -impl Default for ImportCall { +impl Default for EmailImport { fn default() -> Self { Self::new() } } -impl Method for ImportCall { +impl Method for EmailImport { const NAME: &'static str = "Email/import"; } @@ -126,7 +126,7 @@ impl Default for EmailImportObject { #[derive(Deserialize, Serialize, Clone, Debug)] #[serde(rename_all = "camelCase")] #[serde(tag = "type")] -pub enum ImportError { +pub enum EmailImportError { /// The server MAY forbid two Email objects with the same exact content /// `RFC5322`, or even just with the same Message-ID `RFC5322`, to /// coexist within an account. In this case, it MUST reject attempts to @@ -166,7 +166,7 @@ pub enum ImportError { #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] -pub struct ImportResponse { +pub struct EmailImportResponse { /// o accountId: `Id` /// The id of the account used for this call. pub account_id: Id, @@ -186,28 +186,28 @@ pub struct ImportResponse { /// A map of the creation id to an object containing the `id`, /// `blobId`, `threadId`, and `size` properties for each successfully /// imported Email, or null if none. - pub created: Option, ImportEmailResult>>, + pub created: Option, EmailImportResult>>, /// o notCreated: `Id[SetError]|null` /// A map of the creation id to a SetError object for each Email that /// failed to be created, or null if all successful. The possible /// errors are defined above. - pub not_created: Option, ImportError>>, + pub not_created: Option, EmailImportError>>, } -impl std::convert::TryFrom<&RawValue> for ImportResponse { +impl std::convert::TryFrom<&RawValue> for EmailImportResponse { type Error = crate::error::Error; fn try_from(t: &RawValue) -> Result { let res: (String, Self, String) = deserialize_from_str(t.get())?; - assert_eq!(&res.0, &ImportCall::NAME); + assert_eq!(&res.0, &EmailImport::NAME); Ok(res.1) } } #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] -pub struct ImportEmailResult { +pub struct EmailImportResult { pub id: Id, pub blob_id: Id, pub thread_id: Id,