Migrated to AHashMap.
parent
7300ac7b84
commit
45f0aa3d81
|
@ -22,6 +22,7 @@ base64 = "0.13"
|
|||
tokio-tungstenite = { version = "0.17", features = ["rustls-tls-webpki-roots"], optional = true}
|
||||
tokio = { version = "1.16", default-features = false, features = ["io-util"], optional = true }
|
||||
parking_lot = "0.12.0"
|
||||
ahash = {version = "0.7.6", features = ["serde"]}
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use ahash::AHashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
|
@ -24,9 +23,9 @@ pub struct CopyBlobResponse {
|
|||
#[serde(rename = "accountId")]
|
||||
account_id: String,
|
||||
#[serde(rename = "copied")]
|
||||
copied: Option<HashMap<String, String>>,
|
||||
copied: Option<AHashMap<String, String>>,
|
||||
#[serde(rename = "notCopied")]
|
||||
not_copied: Option<HashMap<String, SetError<String>>>,
|
||||
not_copied: Option<AHashMap<String, SetError<String>>>,
|
||||
}
|
||||
|
||||
impl CopyBlobRequest {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::{collections::HashMap, pin::Pin};
|
||||
use std::pin::Pin;
|
||||
|
||||
use ahash::AHashMap;
|
||||
use futures_util::{stream::SplitSink, SinkExt, Stream, StreamExt};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::net::TcpStream;
|
||||
|
@ -34,7 +35,7 @@ struct WebSocketRequest {
|
|||
|
||||
#[serde(rename = "createdIds")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
created_ids: Option<HashMap<String, String>>,
|
||||
created_ids: Option<AHashMap<String, String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
@ -49,7 +50,7 @@ pub struct WebSocketResponse {
|
|||
method_responses: Vec<TaggedMethodResponse>,
|
||||
|
||||
#[serde(rename = "createdIds")]
|
||||
created_ids: Option<HashMap<String, String>>,
|
||||
created_ids: Option<AHashMap<String, String>>,
|
||||
|
||||
#[serde(rename = "sessionState")]
|
||||
session_state: String,
|
||||
|
@ -104,7 +105,7 @@ pub struct WebSocketStateChange {
|
|||
#[serde(rename = "@type")]
|
||||
pub type_: WebSocketStateChangeType,
|
||||
|
||||
pub changed: HashMap<String, HashMap<TypeState, String>>,
|
||||
pub changed: AHashMap<String, AHashMap<TypeState, String>>,
|
||||
|
||||
#[serde(rename = "pushState")]
|
||||
push_state: Option<String>,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use ahash::AHashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::Error;
|
||||
|
@ -26,7 +25,7 @@ pub struct CopyRequest<O: SetObject> {
|
|||
if_in_state: Option<String>,
|
||||
|
||||
#[serde(rename = "create")]
|
||||
create: HashMap<String, O>,
|
||||
create: AHashMap<String, O>,
|
||||
|
||||
#[serde(rename = "onSuccessDestroyOriginal")]
|
||||
on_success_destroy_original: bool,
|
||||
|
@ -51,10 +50,10 @@ pub struct CopyResponse<O: SetObject> {
|
|||
new_state: String,
|
||||
|
||||
#[serde(rename = "created")]
|
||||
created: Option<HashMap<String, O>>,
|
||||
created: Option<AHashMap<String, O>>,
|
||||
|
||||
#[serde(rename = "notCreated")]
|
||||
not_created: Option<HashMap<String, SetError<O::Property>>>,
|
||||
not_created: Option<AHashMap<String, SetError<O::Property>>>,
|
||||
}
|
||||
|
||||
impl<T: SetObject> CopyRequest<T> {
|
||||
|
@ -64,7 +63,7 @@ impl<T: SetObject> CopyRequest<T> {
|
|||
if_from_in_state: None,
|
||||
account_id: params.account_id,
|
||||
if_in_state: None,
|
||||
create: HashMap::new(),
|
||||
create: AHashMap::new(),
|
||||
on_success_destroy_original: false,
|
||||
destroy_from_if_in_state: None,
|
||||
}
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
use crate::{
|
||||
blob::copy::CopyBlobRequest,
|
||||
client::Client,
|
||||
|
@ -18,6 +14,8 @@ use crate::{
|
|||
vacation_response::VacationResponse,
|
||||
Error, Method, Set, URI,
|
||||
};
|
||||
use ahash::AHashMap;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
use super::{
|
||||
changes::ChangesRequest,
|
||||
|
@ -44,7 +42,7 @@ pub struct Request<'x> {
|
|||
|
||||
#[serde(rename = "createdIds")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub created_ids: Option<HashMap<String, String>>,
|
||||
pub created_ids: Option<AHashMap<String, String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{collections::HashMap, fmt};
|
||||
|
||||
use ahash::AHashMap;
|
||||
use serde::{de::Visitor, Deserialize};
|
||||
use std::fmt;
|
||||
|
||||
use crate::{
|
||||
blob::copy::CopyBlobResponse,
|
||||
|
@ -29,7 +29,7 @@ pub struct Response<T> {
|
|||
method_responses: Vec<T>,
|
||||
|
||||
#[serde(rename = "createdIds")]
|
||||
created_ids: Option<HashMap<String, String>>,
|
||||
created_ids: Option<AHashMap<String, String>>,
|
||||
|
||||
#[serde(rename = "sessionState")]
|
||||
session_state: String,
|
||||
|
@ -40,7 +40,7 @@ pub struct Response<T> {
|
|||
impl<T> Response<T> {
|
||||
pub fn new(
|
||||
method_responses: Vec<T>,
|
||||
created_ids: Option<HashMap<String, String>>,
|
||||
created_ids: Option<AHashMap<String, String>>,
|
||||
session_state: String,
|
||||
request_id: Option<String>,
|
||||
) -> Self {
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
email::{MailCapabilities, SubmissionCapabilities},
|
||||
URI,
|
||||
};
|
||||
use ahash::AHashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Session {
|
||||
#[serde(rename = "capabilities")]
|
||||
capabilities: HashMap<String, Capabilities>,
|
||||
capabilities: AHashMap<String, Capabilities>,
|
||||
|
||||
#[serde(rename = "accounts")]
|
||||
accounts: HashMap<String, Account>,
|
||||
accounts: AHashMap<String, Account>,
|
||||
|
||||
#[serde(rename = "primaryAccounts")]
|
||||
primary_accounts: HashMap<String, String>,
|
||||
primary_accounts: AHashMap<String, String>,
|
||||
|
||||
#[serde(rename = "username")]
|
||||
username: String,
|
||||
|
@ -49,7 +47,7 @@ pub struct Account {
|
|||
is_read_only: bool,
|
||||
|
||||
#[serde(rename = "accountCapabilities")]
|
||||
account_capabilities: HashMap<String, Capabilities>,
|
||||
account_capabilities: AHashMap<String, Capabilities>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
use crate::Error;
|
||||
use ahash::AHashMap;
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::{self, Display, Formatter},
|
||||
};
|
||||
|
||||
use crate::Error;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
use super::{request::ResultReference, Object, RequestParams};
|
||||
|
||||
|
@ -27,10 +24,10 @@ pub struct SetRequest<O: SetObject> {
|
|||
if_in_state: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
create: Option<HashMap<String, O>>,
|
||||
create: Option<AHashMap<String, O>>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
update: Option<HashMap<String, O>>,
|
||||
update: Option<AHashMap<String, O>>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
destroy: Option<Vec<String>>,
|
||||
|
@ -53,25 +50,25 @@ pub struct SetResponse<O: SetObject> {
|
|||
old_state: Option<String>,
|
||||
|
||||
#[serde(rename = "newState")]
|
||||
new_state: String,
|
||||
new_state: Option<String>,
|
||||
|
||||
#[serde(rename = "created")]
|
||||
created: Option<HashMap<String, O>>,
|
||||
created: Option<AHashMap<String, O>>,
|
||||
|
||||
#[serde(rename = "updated")]
|
||||
updated: Option<HashMap<String, Option<O>>>,
|
||||
updated: Option<AHashMap<String, Option<O>>>,
|
||||
|
||||
#[serde(rename = "destroyed")]
|
||||
destroyed: Option<Vec<String>>,
|
||||
|
||||
#[serde(rename = "notCreated")]
|
||||
not_created: Option<HashMap<String, SetError<O::Property>>>,
|
||||
not_created: Option<AHashMap<String, SetError<O::Property>>>,
|
||||
|
||||
#[serde(rename = "notUpdated")]
|
||||
not_updated: Option<HashMap<String, SetError<O::Property>>>,
|
||||
not_updated: Option<AHashMap<String, SetError<O::Property>>>,
|
||||
|
||||
#[serde(rename = "notDestroyed")]
|
||||
not_destroyed: Option<HashMap<String, SetError<O::Property>>>,
|
||||
not_destroyed: Option<AHashMap<String, SetError<O::Property>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
|
@ -166,7 +163,7 @@ impl<O: SetObject> SetRequest<O> {
|
|||
let create_id = self.create.as_ref().map_or(0, |c| c.len());
|
||||
let create_id_str = format!("c{}", create_id);
|
||||
self.create
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(create_id_str.clone(), O::new(create_id.into()));
|
||||
self.create
|
||||
.as_mut()
|
||||
|
@ -179,7 +176,7 @@ impl<O: SetObject> SetRequest<O> {
|
|||
let create_id = self.create.as_ref().map_or(0, |c| c.len());
|
||||
let create_id_str = format!("c{}", create_id);
|
||||
self.create
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(create_id_str.clone(), item);
|
||||
create_id_str
|
||||
}
|
||||
|
@ -187,14 +184,14 @@ impl<O: SetObject> SetRequest<O> {
|
|||
pub fn update(&mut self, id: impl Into<String>) -> &mut O {
|
||||
let id: String = id.into();
|
||||
self.update
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(id.clone(), O::new(None));
|
||||
self.update.as_mut().unwrap().get_mut(&id).unwrap()
|
||||
}
|
||||
|
||||
pub fn update_item(&mut self, id: impl Into<String>, item: O) {
|
||||
self.update
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(id.into(), item);
|
||||
}
|
||||
|
||||
|
@ -231,11 +228,11 @@ impl<O: SetObject> SetResponse<O> {
|
|||
}
|
||||
|
||||
pub fn new_state(&self) -> &str {
|
||||
self.new_state.as_ref()
|
||||
self.new_state.as_deref().unwrap_or("")
|
||||
}
|
||||
|
||||
pub fn take_new_state(&mut self) -> String {
|
||||
std::mem::take(&mut self.new_state)
|
||||
self.new_state.take().unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn created(&mut self, id: &str) -> crate::Result<O> {
|
||||
|
@ -410,6 +407,6 @@ pub fn list_not_set<O>(list: &Option<Vec<O>>) -> bool {
|
|||
matches!(list, Some(list) if list.is_empty() )
|
||||
}
|
||||
|
||||
pub fn map_not_set<K, V>(list: &Option<HashMap<K, V>>) -> bool {
|
||||
pub fn map_not_set<K, V>(list: &Option<AHashMap<K, V>>) -> bool {
|
||||
matches!(list, Some(list) if list.is_empty() )
|
||||
}
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
core::{
|
||||
request::ResultReference,
|
||||
|
@ -11,6 +6,9 @@ use crate::{
|
|||
},
|
||||
Error,
|
||||
};
|
||||
use ahash::AHashMap;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{Email, Property};
|
||||
|
||||
|
@ -23,7 +21,7 @@ pub struct EmailImportRequest {
|
|||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
if_in_state: Option<String>,
|
||||
|
||||
emails: HashMap<String, EmailImport>,
|
||||
emails: AHashMap<String, EmailImport>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
|
@ -36,7 +34,7 @@ pub struct EmailImport {
|
|||
|
||||
#[serde(rename = "mailboxIds")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
mailbox_ids: Option<HashMap<String, bool>>,
|
||||
mailbox_ids: Option<AHashMap<String, bool>>,
|
||||
|
||||
#[serde(rename = "#mailboxIds")]
|
||||
#[serde(skip_deserializing)]
|
||||
|
@ -44,7 +42,7 @@ pub struct EmailImport {
|
|||
mailbox_ids_ref: Option<ResultReference>,
|
||||
|
||||
#[serde(rename = "keywords")]
|
||||
keywords: HashMap<String, bool>,
|
||||
keywords: AHashMap<String, bool>,
|
||||
|
||||
#[serde(rename = "receivedAt")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -63,10 +61,10 @@ pub struct EmailImportResponse {
|
|||
new_state: String,
|
||||
|
||||
#[serde(rename = "created")]
|
||||
created: Option<HashMap<String, Email>>,
|
||||
created: Option<AHashMap<String, Email>>,
|
||||
|
||||
#[serde(rename = "notCreated")]
|
||||
not_created: Option<HashMap<String, SetError<Property>>>,
|
||||
not_created: Option<AHashMap<String, SetError<Property>>>,
|
||||
}
|
||||
|
||||
impl EmailImportRequest {
|
||||
|
@ -74,7 +72,7 @@ impl EmailImportRequest {
|
|||
EmailImportRequest {
|
||||
account_id: params.account_id,
|
||||
if_in_state: None,
|
||||
emails: HashMap::new(),
|
||||
emails: AHashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +104,7 @@ impl EmailImport {
|
|||
blob_id,
|
||||
mailbox_ids: None,
|
||||
mailbox_ids_ref: None,
|
||||
keywords: HashMap::new(),
|
||||
keywords: AHashMap::new(),
|
||||
received_at: None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,10 @@ pub mod parse;
|
|||
pub mod query;
|
||||
pub mod search_snippet;
|
||||
pub mod set;
|
||||
|
||||
use ahash::AHashMap;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{de::Visitor, Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::{self, Display, Formatter},
|
||||
};
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
use crate::{
|
||||
core::{changes::ChangesObject, request::ResultReference, Object},
|
||||
|
@ -64,7 +61,7 @@ pub struct Email<State = Get> {
|
|||
|
||||
#[serde(rename = "mailboxIds")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
mailbox_ids: Option<HashMap<String, bool>>,
|
||||
mailbox_ids: Option<AHashMap<String, bool>>,
|
||||
|
||||
#[serde(rename = "#mailboxIds")]
|
||||
#[serde(skip_deserializing)]
|
||||
|
@ -73,7 +70,7 @@ pub struct Email<State = Get> {
|
|||
|
||||
#[serde(rename = "keywords")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
keywords: Option<HashMap<String, bool>>,
|
||||
keywords: Option<AHashMap<String, bool>>,
|
||||
|
||||
#[serde(rename = "size")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -153,7 +150,7 @@ pub struct Email<State = Get> {
|
|||
|
||||
#[serde(rename = "bodyValues")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
body_values: Option<HashMap<String, EmailBodyValue>>,
|
||||
body_values: Option<AHashMap<String, EmailBodyValue>>,
|
||||
|
||||
#[serde(rename = "textBody")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -176,13 +173,13 @@ pub struct Email<State = Get> {
|
|||
preview: Option<String>,
|
||||
|
||||
#[serde(flatten)]
|
||||
#[serde(skip_serializing_if = "HashMap::is_empty")]
|
||||
headers: HashMap<Header, Option<HeaderValue>>,
|
||||
#[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
|
||||
headers: AHashMap<Header, Option<HeaderValue>>,
|
||||
|
||||
#[serde(flatten)]
|
||||
#[serde(skip_deserializing)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
patch: Option<HashMap<String, bool>>,
|
||||
patch: Option<AHashMap<String, bool>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
@ -240,7 +237,7 @@ pub struct EmailBodyPart<State = Get> {
|
|||
|
||||
#[serde(flatten)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
header: Option<HashMap<Header, HeaderValue>>,
|
||||
header: Option<AHashMap<Header, HeaderValue>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
@ -948,41 +945,16 @@ impl From<Email> for TestEmail {
|
|||
reply_to: email.reply_to,
|
||||
subject: email.subject,
|
||||
sent_at: email.sent_at,
|
||||
body_structure: email.body_structure.map(|b| b.into_sorted_part().into()),
|
||||
body_structure: email.body_structure,
|
||||
body_values: email
|
||||
.body_values
|
||||
.map(|body_values| body_values.into_iter().collect()),
|
||||
text_body: email
|
||||
.text_body
|
||||
.map(|parts| parts.into_iter().map(|b| b.into_sorted_part()).collect()),
|
||||
html_body: email
|
||||
.html_body
|
||||
.map(|parts| parts.into_iter().map(|b| b.into_sorted_part()).collect()),
|
||||
attachments: email
|
||||
.attachments
|
||||
.map(|parts| parts.into_iter().map(|b| b.into_sorted_part()).collect()),
|
||||
text_body: email.text_body,
|
||||
html_body: email.html_body,
|
||||
attachments: email.attachments,
|
||||
has_attachment: email.has_attachment,
|
||||
preview: email.preview,
|
||||
headers: email.headers.into_iter().collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "debug")]
|
||||
impl EmailBodyPart {
|
||||
pub fn sort_headers(&mut self) {
|
||||
if let Some(headers) = self.headers.as_mut() {
|
||||
headers.sort_unstable_by_key(|h| (h.name.clone(), h.value.clone()));
|
||||
}
|
||||
if let Some(subparts) = self.sub_parts.as_mut() {
|
||||
for sub_part in subparts {
|
||||
sub_part.sort_headers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_sorted_part(mut self) -> Self {
|
||||
self.sort_headers();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{core::RequestParams, Error};
|
||||
|
||||
use super::{BodyProperty, Email, Property};
|
||||
use crate::{core::RequestParams, Error};
|
||||
use ahash::AHashMap;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct EmailParseRequest {
|
||||
|
@ -45,7 +43,7 @@ pub struct EmailParseResponse {
|
|||
account_id: String,
|
||||
|
||||
#[serde(rename = "parsed")]
|
||||
parsed: Option<HashMap<String, Email>>,
|
||||
parsed: Option<AHashMap<String, Email>>,
|
||||
|
||||
#[serde(rename = "notParsable")]
|
||||
not_parsable: Option<Vec<String>>,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use super::{
|
||||
Email, EmailAddress, EmailAddressGroup, EmailBodyPart, EmailBodyValue, EmailHeader, Header,
|
||||
HeaderValue,
|
||||
};
|
||||
use crate::{
|
||||
core::{
|
||||
request::ResultReference,
|
||||
|
@ -7,11 +9,7 @@ use crate::{
|
|||
},
|
||||
Get, Set,
|
||||
};
|
||||
|
||||
use super::{
|
||||
Email, EmailAddress, EmailAddressGroup, EmailBodyPart, EmailBodyValue, EmailHeader, Header,
|
||||
HeaderValue,
|
||||
};
|
||||
use ahash::AHashMap;
|
||||
|
||||
impl Email<Set> {
|
||||
pub fn mailbox_ids<T, U>(&mut self, mailbox_ids: T) -> &mut Self
|
||||
|
@ -33,7 +31,7 @@ impl Email<Set> {
|
|||
pub fn mailbox_id(&mut self, mailbox_id: &str, set: bool) -> &mut Self {
|
||||
self.mailbox_ids = None;
|
||||
self.patch
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(format!("mailboxIds/{}", mailbox_id), set);
|
||||
self
|
||||
}
|
||||
|
@ -50,7 +48,7 @@ impl Email<Set> {
|
|||
pub fn keyword(&mut self, keyword: &str, set: bool) -> &mut Self {
|
||||
self.keywords = None;
|
||||
self.patch
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(format!("keywords/{}", keyword), set);
|
||||
self
|
||||
}
|
||||
|
@ -153,7 +151,7 @@ impl Email<Set> {
|
|||
|
||||
pub fn body_value(&mut self, id: String, body_value: impl Into<EmailBodyValue>) -> &mut Self {
|
||||
self.body_values
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(id, body_value.into());
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{core::get::GetObject, Get, Set};
|
||||
|
||||
use super::{Address, Delivered, DeliveryStatus, Displayed, EmailSubmission, UndoStatus};
|
||||
use crate::{core::get::GetObject, Get, Set};
|
||||
use ahash::AHashMap;
|
||||
|
||||
impl EmailSubmission<Get> {
|
||||
pub fn id(&self) -> Option<&str> {
|
||||
|
@ -45,7 +43,7 @@ impl EmailSubmission<Get> {
|
|||
self.delivery_status.as_ref().and_then(|ds| ds.get(email))
|
||||
}
|
||||
|
||||
pub fn delivery_status(&self) -> Option<&HashMap<String, DeliveryStatus>> {
|
||||
pub fn delivery_status(&self) -> Option<&AHashMap<String, DeliveryStatus>> {
|
||||
self.delivery_status.as_ref()
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ pub mod helpers;
|
|||
pub mod query;
|
||||
pub mod set;
|
||||
|
||||
use std::{collections::HashMap, fmt::Display};
|
||||
|
||||
use ahash::AHashMap;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
|
||||
use crate::{
|
||||
core::{changes::ChangesObject, Object},
|
||||
|
@ -18,7 +18,7 @@ use crate::{
|
|||
pub struct SetArguments {
|
||||
#[serde(rename = "onSuccessUpdateEmail")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
on_success_update_email: Option<HashMap<String, Email<Set>>>,
|
||||
on_success_update_email: Option<AHashMap<String, Email<Set>>>,
|
||||
#[serde(rename = "onSuccessDestroyEmail")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
on_success_destroy_email: Option<Vec<String>>,
|
||||
|
@ -62,7 +62,7 @@ pub struct EmailSubmission<State = Get> {
|
|||
|
||||
#[serde(rename = "deliveryStatus")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
delivery_status: Option<HashMap<String, DeliveryStatus>>,
|
||||
delivery_status: Option<AHashMap<String, DeliveryStatus>>,
|
||||
|
||||
#[serde(rename = "dsnBlobIds")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -88,7 +88,7 @@ pub struct Address<State = Get> {
|
|||
_state: std::marker::PhantomData<State>,
|
||||
|
||||
email: String,
|
||||
parameters: Option<HashMap<String, Option<String>>>,
|
||||
parameters: Option<AHashMap<String, Option<String>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{core::set::SetObject, email::Email, Get, Set};
|
||||
|
||||
use super::{Address, EmailSubmission, Envelope, SetArguments, UndoStatus};
|
||||
use crate::{core::set::SetObject, email::Email, Get, Set};
|
||||
use ahash::AHashMap;
|
||||
|
||||
impl EmailSubmission<Set> {
|
||||
pub fn identity_id(&mut self, identity_id: impl Into<String>) -> &mut Self {
|
||||
|
@ -97,7 +95,7 @@ impl Address<Set> {
|
|||
value: Option<impl Into<String>>,
|
||||
) -> Self {
|
||||
self.parameters
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(parameter.into(), value.map(|s| s.into()));
|
||||
self
|
||||
}
|
||||
|
@ -155,7 +153,7 @@ impl SetArguments {
|
|||
fn on_success_update_email_(&mut self, id: impl Into<String>) -> &mut Email<Set> {
|
||||
let id = id.into();
|
||||
self.on_success_update_email
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(id.clone(), Email::new(None));
|
||||
self.on_success_update_email
|
||||
.as_mut()
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
pub mod parser;
|
||||
pub mod stream;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{core::session::URLParser, TypeState};
|
||||
use ahash::AHashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub enum URLParameter {
|
||||
Types,
|
||||
|
@ -27,11 +25,11 @@ impl URLParser for URLParameter {
|
|||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Changes {
|
||||
id: Option<String>,
|
||||
changes: HashMap<String, HashMap<TypeState, String>>,
|
||||
changes: AHashMap<String, AHashMap<TypeState, String>>,
|
||||
}
|
||||
|
||||
impl Changes {
|
||||
pub fn new(id: Option<String>, changes: HashMap<String, HashMap<TypeState, String>>) -> Self {
|
||||
pub fn new(id: Option<String>, changes: AHashMap<String, AHashMap<TypeState, String>>) -> Self {
|
||||
Self { id, changes }
|
||||
}
|
||||
|
||||
|
@ -39,7 +37,7 @@ impl Changes {
|
|||
self.id.as_deref()
|
||||
}
|
||||
|
||||
pub fn account_changes(&mut self, account_id: &str) -> Option<HashMap<TypeState, String>> {
|
||||
pub fn account_changes(&mut self, account_id: &str) -> Option<AHashMap<TypeState, String>> {
|
||||
self.changes.remove(account_id)
|
||||
}
|
||||
|
||||
|
@ -57,7 +55,7 @@ impl Changes {
|
|||
.any(|changes| changes.contains_key(&type_))
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> HashMap<String, HashMap<TypeState, String>> {
|
||||
pub fn into_inner(self) -> AHashMap<String, AHashMap<TypeState, String>> {
|
||||
self.changes
|
||||
}
|
||||
|
||||
|
|
|
@ -93,9 +93,9 @@ impl EventParser {
|
|||
} else {
|
||||
None
|
||||
},
|
||||
changes: std::collections::HashMap::from_iter([(
|
||||
changes: ahash::AHashMap::from_iter([(
|
||||
"ping".to_string(),
|
||||
std::collections::HashMap::new(),
|
||||
ahash::AHashMap::new(),
|
||||
)]),
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::core::error::MethodError;
|
||||
use crate::core::error::ProblemDetails;
|
||||
use crate::core::set::SetError;
|
||||
use std::{collections::HashMap, fmt::Display};
|
||||
|
||||
use ahash::AHashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
|
||||
pub mod blob;
|
||||
pub mod client;
|
||||
|
@ -154,7 +154,7 @@ pub enum StateChangeType {
|
|||
pub struct StateChange {
|
||||
#[serde(rename = "@type")]
|
||||
pub type_: StateChangeType,
|
||||
pub changed: HashMap<String, HashMap<TypeState, String>>,
|
||||
pub changed: AHashMap<String, AHashMap<TypeState, String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{core::get::GetObject, principal::ACL, Get, Set};
|
||||
|
||||
use super::{Mailbox, MailboxRights, Role};
|
||||
use crate::{core::get::GetObject, principal::ACL, Get, Set};
|
||||
use ahash::AHashMap;
|
||||
|
||||
impl Mailbox<Get> {
|
||||
pub fn id(&self) -> Option<&str> {
|
||||
|
@ -53,11 +51,11 @@ impl Mailbox<Get> {
|
|||
self.my_rights.as_ref()
|
||||
}
|
||||
|
||||
pub fn acl(&self) -> Option<&HashMap<String, Vec<ACL>>> {
|
||||
pub fn acl(&self) -> Option<&AHashMap<String, Vec<ACL>>> {
|
||||
self.acl.as_ref()
|
||||
}
|
||||
|
||||
pub fn take_acl(&mut self) -> Option<HashMap<String, Vec<ACL>>> {
|
||||
pub fn take_acl(&mut self) -> Option<AHashMap<String, Vec<ACL>>> {
|
||||
self.acl.take()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,16 +3,15 @@ pub mod helpers;
|
|||
pub mod query;
|
||||
pub mod set;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
|
||||
use crate::core::changes::ChangesObject;
|
||||
use crate::core::set::{map_not_set, string_not_set};
|
||||
use crate::core::Object;
|
||||
use crate::mailbox::set::role_not_set;
|
||||
use crate::principal::ACL;
|
||||
use crate::{Get, Set};
|
||||
use ahash::AHashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Default)]
|
||||
pub struct SetArguments {
|
||||
|
@ -88,12 +87,12 @@ pub struct Mailbox<State = Get> {
|
|||
is_subscribed: Option<bool>,
|
||||
|
||||
#[serde(skip_serializing_if = "map_not_set")]
|
||||
acl: Option<HashMap<String, Vec<ACL>>>,
|
||||
acl: Option<AHashMap<String, Vec<ACL>>>,
|
||||
|
||||
#[serde(flatten)]
|
||||
#[serde(skip_deserializing)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
acl_patch: Option<HashMap<String, ACLPatch>>,
|
||||
acl_patch: Option<AHashMap<String, ACLPatch>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{core::set::SetObject, principal::ACL, Get, Set};
|
||||
|
||||
use super::{ACLPatch, Mailbox, Role, SetArguments};
|
||||
use crate::{core::set::SetObject, principal::ACL, Get, Set};
|
||||
use ahash::AHashMap;
|
||||
|
||||
impl Mailbox<Set> {
|
||||
pub fn name(&mut self, name: impl Into<String>) -> &mut Self {
|
||||
|
@ -54,7 +52,7 @@ impl Mailbox<Set> {
|
|||
}
|
||||
|
||||
pub fn acl(&mut self, id: &str, acl: impl IntoIterator<Item = ACL>) -> &mut Self {
|
||||
self.acl_patch.get_or_insert_with(HashMap::new).insert(
|
||||
self.acl_patch.get_or_insert_with(AHashMap::new).insert(
|
||||
format!("acl/{}", id),
|
||||
ACLPatch::Replace(acl.into_iter().collect()),
|
||||
);
|
||||
|
@ -63,7 +61,7 @@ impl Mailbox<Set> {
|
|||
|
||||
pub fn acl_set(&mut self, id: &str, acl: ACL, set: bool) -> &mut Self {
|
||||
self.acl_patch
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.get_or_insert_with(AHashMap::new)
|
||||
.insert(format!("acl/{}/{}", id, acl), ACLPatch::Set(set));
|
||||
self
|
||||
}
|
||||
|
@ -91,7 +89,7 @@ impl SetObject for Mailbox<Set> {
|
|||
unread_threads: None,
|
||||
my_rights: None,
|
||||
is_subscribed: None,
|
||||
acl: HashMap::with_capacity(0).into(),
|
||||
acl: AHashMap::with_capacity(0).into(),
|
||||
acl_patch: None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{core::get::GetObject, Get, Set};
|
||||
|
||||
use super::{Principal, Type, ACL, DKIM};
|
||||
use crate::{core::get::GetObject, Get, Set};
|
||||
use ahash::AHashMap;
|
||||
|
||||
impl Principal<Get> {
|
||||
pub fn id(&self) -> Option<&str> {
|
||||
|
@ -57,7 +55,7 @@ impl Principal<Get> {
|
|||
self.dkim.as_ref()
|
||||
}
|
||||
|
||||
pub fn acl(&self) -> Option<&HashMap<String, Vec<ACL>>> {
|
||||
pub fn acl(&self) -> Option<&AHashMap<String, Vec<ACL>>> {
|
||||
self.acl.as_ref()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ pub mod query;
|
|||
pub mod set;
|
||||
|
||||
use crate::core::set::{list_not_set, map_not_set, string_not_set};
|
||||
use std::{collections::HashMap, fmt::Display};
|
||||
|
||||
use ahash::AHashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Display;
|
||||
|
||||
use crate::{
|
||||
core::{changes::ChangesObject, Object},
|
||||
|
@ -49,7 +49,7 @@ pub struct Principal<State = Get> {
|
|||
#[serde(skip_serializing_if = "list_not_set")]
|
||||
members: Option<Vec<String>>,
|
||||
#[serde(skip_serializing_if = "map_not_set")]
|
||||
acl: Option<HashMap<String, Vec<ACL>>>,
|
||||
acl: Option<AHashMap<String, Vec<ACL>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Copy)]
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{core::set::SetObject, Get, Set};
|
||||
|
||||
use super::{Principal, Type, ACL, DKIM};
|
||||
use crate::{core::set::SetObject, Get, Set};
|
||||
use ahash::AHashMap;
|
||||
|
||||
impl Principal<Set> {
|
||||
pub fn name(&mut self, name: impl Into<String>) -> &mut Self {
|
||||
|
@ -50,7 +48,7 @@ impl Principal<Set> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn acl(&mut self, acl: Option<HashMap<String, Vec<ACL>>>) -> &mut Self {
|
||||
pub fn acl(&mut self, acl: Option<AHashMap<String, Vec<ACL>>>) -> &mut Self {
|
||||
self.acl = acl;
|
||||
self
|
||||
}
|
||||
|
@ -103,7 +101,7 @@ impl SetObject for Principal<Set> {
|
|||
quota: None,
|
||||
picture: "".to_string().into(),
|
||||
members: Vec::with_capacity(0).into(),
|
||||
acl: HashMap::with_capacity(0).into(),
|
||||
acl: AHashMap::with_capacity(0).into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue