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:
Jeremiah Russell
2025-10-01 14:51:53 +01:00
committed by Jeremiah Russell
parent 6f9801d5e7
commit 3426d3e60b

View File

@@ -1,6 +1,7 @@
use clap::Parser;
use cull_gmail::List;
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
@@ -9,24 +10,7 @@ pub struct ListCli {}
impl ListCli {
pub(crate) async fn run(&self, hub: Gmail<HttpsConnector<HttpConnector>>) {
let result = hub.users().messages_list("me").doit().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:?}"),
}
let list = List::new(hub);
list.run().await;
}
}