✨ feat(list): integrate List struct for message listing
- integrate List struct for message listing - move message listing logic to List struct
This commit is contained in:
committed by
Jeremiah Russell
parent
6f9801d5e7
commit
3426d3e60b
@@ -1,6 +1,7 @@
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use cull_gmail::List;
|
||||||
use google_gmail1::{
|
use google_gmail1::{
|
||||||
Error, Gmail, hyper_rustls::HttpsConnector, hyper_util::client::legacy::connect::HttpConnector,
|
Gmail, hyper_rustls::HttpsConnector, hyper_util::client::legacy::connect::HttpConnector,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Command line options for the list subcommand
|
/// Command line options for the list subcommand
|
||||||
@@ -9,24 +10,7 @@ pub struct ListCli {}
|
|||||||
|
|
||||||
impl ListCli {
|
impl ListCli {
|
||||||
pub(crate) async fn run(&self, hub: Gmail<HttpsConnector<HttpConnector>>) {
|
pub(crate) async fn run(&self, hub: Gmail<HttpsConnector<HttpConnector>>) {
|
||||||
let result = hub.users().messages_list("me").doit().await;
|
let list = List::new(hub);
|
||||||
|
list.run().await;
|
||||||
match result {
|
|
||||||
Err(e) => match e {
|
|
||||||
// The Error enum provides details about what exactly happened.
|
|
||||||
// You can also just use its `Debug`, `Display` or `Error` traits
|
|
||||||
Error::HttpError(_)
|
|
||||||
| Error::Io(_)
|
|
||||||
| Error::MissingAPIKey
|
|
||||||
| Error::MissingToken(_)
|
|
||||||
| Error::Cancelled
|
|
||||||
| Error::UploadSizeLimitExceeded(_, _)
|
|
||||||
| Error::Failure(_)
|
|
||||||
| Error::BadRequest(_)
|
|
||||||
| Error::FieldClash(_)
|
|
||||||
| Error::JsonDecodeError(_, _) => println!("{e}"),
|
|
||||||
},
|
|
||||||
Ok(res) => println!("Success: {res:?}"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user