Fixes and improvements.
parent
8b20a25461
commit
f5e9922294
|
@ -27,7 +27,7 @@ impl Client {
|
||||||
blob: Vec<u8>,
|
blob: Vec<u8>,
|
||||||
content_type: Option<&str>,
|
content_type: Option<&str>,
|
||||||
) -> crate::Result<UploadResponse> {
|
) -> crate::Result<UploadResponse> {
|
||||||
let account_id = account_id.unwrap_or(self.default_account_id());
|
let account_id = account_id.unwrap_or_else(|| self.default_account_id());
|
||||||
let mut upload_url =
|
let mut upload_url =
|
||||||
String::with_capacity(self.session().upload_url().len() + account_id.len());
|
String::with_capacity(self.session().upload_url().len() + account_id.len());
|
||||||
|
|
||||||
|
|
|
@ -92,14 +92,26 @@ impl<O: ChangesObject> ChangesResponse<O> {
|
||||||
&self.created
|
&self.created
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn take_created(&mut self) -> Vec<String> {
|
||||||
|
std::mem::take(&mut self.created)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn updated(&self) -> &[String] {
|
pub fn updated(&self) -> &[String] {
|
||||||
&self.updated
|
&self.updated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn take_updated(&mut self) -> Vec<String> {
|
||||||
|
std::mem::take(&mut self.updated)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn destroyed(&self) -> &[String] {
|
pub fn destroyed(&self) -> &[String] {
|
||||||
&self.destroyed
|
&self.destroyed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn take_destroyed(&mut self) -> Vec<String> {
|
||||||
|
std::mem::take(&mut self.destroyed)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn arguments(&self) -> &O::ChangesResponse {
|
pub fn arguments(&self) -> &O::ChangesResponse {
|
||||||
&self.arguments
|
&self.arguments
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,10 +162,13 @@ impl Client {
|
||||||
pub async fn email_changes(
|
pub async fn email_changes(
|
||||||
&self,
|
&self,
|
||||||
since_state: impl Into<String>,
|
since_state: impl Into<String>,
|
||||||
max_changes: usize,
|
max_changes: Option<usize>,
|
||||||
) -> crate::Result<ChangesResponse<Email<Get>>> {
|
) -> crate::Result<ChangesResponse<Email<Get>>> {
|
||||||
let mut request = self.build();
|
let mut request = self.build();
|
||||||
request.changes_email(since_state).max_changes(max_changes);
|
let changes_request = request.changes_email(since_state);
|
||||||
|
if let Some(max_changes) = max_changes {
|
||||||
|
changes_request.max_changes(max_changes);
|
||||||
|
}
|
||||||
request.send_single().await
|
request.send_single().await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ pub enum Filter {
|
||||||
value: Vec<String>,
|
value: Vec<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Stalwart specific
|
// Non-standard
|
||||||
Id {
|
Id {
|
||||||
#[serde(rename = "id")]
|
#[serde(rename = "id")]
|
||||||
value: Vec<String>,
|
value: Vec<String>,
|
||||||
|
@ -121,8 +121,6 @@ pub enum Comparator {
|
||||||
From,
|
From,
|
||||||
#[serde(rename = "to")]
|
#[serde(rename = "to")]
|
||||||
To,
|
To,
|
||||||
#[serde(rename = "cc")]
|
|
||||||
Cc,
|
|
||||||
#[serde(rename = "subject")]
|
#[serde(rename = "subject")]
|
||||||
Subject,
|
Subject,
|
||||||
#[serde(rename = "sentAt")]
|
#[serde(rename = "sentAt")]
|
||||||
|
@ -133,6 +131,10 @@ pub enum Comparator {
|
||||||
AllInThreadHaveKeyword { keyword: String },
|
AllInThreadHaveKeyword { keyword: String },
|
||||||
#[serde(rename = "someInThreadHaveKeyword")]
|
#[serde(rename = "someInThreadHaveKeyword")]
|
||||||
SomeInThreadHaveKeyword { keyword: String },
|
SomeInThreadHaveKeyword { keyword: String },
|
||||||
|
|
||||||
|
// Non-standard
|
||||||
|
#[serde(rename = "cc")]
|
||||||
|
Cc,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Filter {
|
impl Filter {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{pin::Pin, time::Duration};
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::{client::Client, core::session::URLPart, event_source::parser::EventParser, TypeState};
|
use crate::{client::Client, core::session::URLPart, event_source::parser::EventParser, TypeState};
|
||||||
use futures_util::{Stream, StreamExt};
|
use futures_util::{Stream, StreamExt};
|
||||||
|
@ -13,7 +13,7 @@ impl Client {
|
||||||
close_after_state: bool,
|
close_after_state: bool,
|
||||||
ping: Option<u32>,
|
ping: Option<u32>,
|
||||||
last_event_id: Option<&str>,
|
last_event_id: Option<&str>,
|
||||||
) -> crate::Result<Pin<Box<impl Stream<Item = crate::Result<Changes>>>>> {
|
) -> crate::Result<impl Stream<Item = crate::Result<Changes>> + Unpin> {
|
||||||
let mut event_source_url = String::with_capacity(self.session().event_source_url().len());
|
let mut event_source_url = String::with_capacity(self.session().event_source_url().len());
|
||||||
|
|
||||||
for part in self.event_source_url() {
|
for part in self.event_source_url() {
|
||||||
|
|
Loading…
Reference in New Issue