mirror of
https://github.com/soywod/himalaya.git
synced 2024-09-05 18:41:11 +00:00
review read command
This commit is contained in:
parent
d706a13e5e
commit
7a43bdd46e
|
@ -29,7 +29,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
smtp::service::SmtpServiceInterface,
|
smtp::service::SmtpServiceInterface,
|
||||||
},
|
},
|
||||||
output::service::{OutputService, OutputServiceInterface},
|
output::service::OutputServiceInterface,
|
||||||
ui::{
|
ui::{
|
||||||
choice::{self, PostEditChoice},
|
choice::{self, PostEditChoice},
|
||||||
editor,
|
editor,
|
||||||
|
@ -37,7 +37,11 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: move this function to the right folder
|
// TODO: move this function to the right folder
|
||||||
fn msg_interaction<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface>(
|
fn msg_interaction<
|
||||||
|
OutputService: OutputServiceInterface,
|
||||||
|
ImapService: ImapServiceInterface,
|
||||||
|
SmtpService: SmtpServiceInterface,
|
||||||
|
>(
|
||||||
output: &OutputService,
|
output: &OutputService,
|
||||||
msg: &mut Msg,
|
msg: &mut Msg,
|
||||||
imap: &mut ImapService,
|
imap: &mut ImapService,
|
||||||
|
@ -180,7 +184,11 @@ pub fn delete<OutputService: OutputServiceInterface, ImapService: ImapServiceInt
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Forward the given message UID from the selected mailbox.
|
/// Forward the given message UID from the selected mailbox.
|
||||||
pub fn forward<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface>(
|
pub fn forward<
|
||||||
|
OutputService: OutputServiceInterface,
|
||||||
|
ImapService: ImapServiceInterface,
|
||||||
|
SmtpService: SmtpServiceInterface,
|
||||||
|
>(
|
||||||
uid: &str,
|
uid: &str,
|
||||||
attachments_paths: Vec<&str>,
|
attachments_paths: Vec<&str>,
|
||||||
account: &Account,
|
account: &Account,
|
||||||
|
@ -201,7 +209,7 @@ pub fn forward<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List messages with pagination from the selected mailbox.
|
/// List messages with pagination from the selected mailbox.
|
||||||
pub fn list<ImapService: ImapServiceInterface>(
|
pub fn list<OutputService: OutputServiceInterface, ImapService: ImapServiceInterface>(
|
||||||
page_size: Option<usize>,
|
page_size: Option<usize>,
|
||||||
page: usize,
|
page: usize,
|
||||||
account: &Account,
|
account: &Account,
|
||||||
|
@ -224,7 +232,11 @@ pub fn list<ImapService: ImapServiceInterface>(
|
||||||
/// Parse and edit a message from a [mailto] URL string.
|
/// Parse and edit a message from a [mailto] URL string.
|
||||||
///
|
///
|
||||||
/// [mailto]: https://en.wikipedia.org/wiki/Mailto
|
/// [mailto]: https://en.wikipedia.org/wiki/Mailto
|
||||||
pub fn mailto<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface>(
|
pub fn mailto<
|
||||||
|
OutputService: OutputServiceInterface,
|
||||||
|
ImapService: ImapServiceInterface,
|
||||||
|
SmtpService: SmtpServiceInterface,
|
||||||
|
>(
|
||||||
url: &Url,
|
url: &Url,
|
||||||
account: &Account,
|
account: &Account,
|
||||||
output: &OutputService,
|
output: &OutputService,
|
||||||
|
@ -295,7 +307,8 @@ pub fn move_<OutputService: OutputServiceInterface, ImapService: ImapServiceInte
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read<ImapService: ImapServiceInterface>(
|
/// Read a message from the given UID.
|
||||||
|
pub fn read<OutputService: OutputServiceInterface, ImapService: ImapServiceInterface>(
|
||||||
uid: &str,
|
uid: &str,
|
||||||
// TODO: use the mime to select the right body
|
// TODO: use the mime to select the right body
|
||||||
_mime: String,
|
_mime: String,
|
||||||
|
@ -313,7 +326,11 @@ pub fn read<ImapService: ImapServiceInterface>(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reply<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface>(
|
pub fn reply<
|
||||||
|
OutputService: OutputServiceInterface,
|
||||||
|
ImapService: ImapServiceInterface,
|
||||||
|
SmtpService: SmtpServiceInterface,
|
||||||
|
>(
|
||||||
uid: &str,
|
uid: &str,
|
||||||
all: bool,
|
all: bool,
|
||||||
attachments_paths: Vec<&str>,
|
attachments_paths: Vec<&str>,
|
||||||
|
@ -349,7 +366,7 @@ pub fn save<ImapService: ImapServiceInterface>(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn search<ImapService: ImapServiceInterface>(
|
pub fn search<OutputService: OutputServiceInterface, ImapService: ImapServiceInterface>(
|
||||||
page_size: Option<usize>,
|
page_size: Option<usize>,
|
||||||
page: usize,
|
page: usize,
|
||||||
query: String,
|
query: String,
|
||||||
|
@ -370,7 +387,11 @@ pub fn search<ImapService: ImapServiceInterface>(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface>(
|
pub fn send<
|
||||||
|
OutputService: OutputServiceInterface,
|
||||||
|
ImapService: ImapServiceInterface,
|
||||||
|
SmtpService: SmtpServiceInterface,
|
||||||
|
>(
|
||||||
msg: &str,
|
msg: &str,
|
||||||
output: &OutputService,
|
output: &OutputService,
|
||||||
imap: &mut ImapService,
|
imap: &mut ImapService,
|
||||||
|
@ -400,7 +421,11 @@ pub fn send<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface>(
|
pub fn write<
|
||||||
|
OutputService: OutputServiceInterface,
|
||||||
|
ImapService: ImapServiceInterface,
|
||||||
|
SmtpService: SmtpServiceInterface,
|
||||||
|
>(
|
||||||
attachments_paths: Vec<&str>,
|
attachments_paths: Vec<&str>,
|
||||||
account: &Account,
|
account: &Account,
|
||||||
output: &OutputService,
|
output: &OutputService,
|
||||||
|
|
|
@ -59,6 +59,7 @@ impl<T: Serialize> OutputJson<T> {
|
||||||
|
|
||||||
pub trait OutputServiceInterface {
|
pub trait OutputServiceInterface {
|
||||||
fn print<T: Serialize + fmt::Display>(&self, data: T) -> Result<()>;
|
fn print<T: Serialize + fmt::Display>(&self, data: T) -> Result<()>;
|
||||||
|
fn is_json(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -66,13 +67,6 @@ pub struct OutputService {
|
||||||
fmt: OutputFmt,
|
fmt: OutputFmt,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutputService {
|
|
||||||
/// Returns true, if the formatting should be json.
|
|
||||||
pub fn is_json(&self) -> bool {
|
|
||||||
self.fmt == OutputFmt::Json
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl OutputServiceInterface for OutputService {
|
impl OutputServiceInterface for OutputService {
|
||||||
/// Print the provided item out according to the formatting setting when you created this
|
/// Print the provided item out according to the formatting setting when you created this
|
||||||
/// struct.
|
/// struct.
|
||||||
|
@ -87,6 +81,11 @@ impl OutputServiceInterface for OutputService {
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true, if the formatting should be json.
|
||||||
|
fn is_json(&self) -> bool {
|
||||||
|
self.fmt == OutputFmt::Json
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for OutputService {
|
impl Default for OutputService {
|
||||||
|
|
Loading…
Reference in a new issue