♻️ refactor(list): improve max results handling
- change DEFAULT_MAX_RESULTS to const &str for flexibility - add setter and getter for max_results field
This commit is contained in:
committed by
Jeremiah Russell
parent
74ab1660ff
commit
b4a782409f
15
src/list.rs
15
src/list.rs
@@ -10,7 +10,8 @@ use google_gmail1::{
|
|||||||
|
|
||||||
use crate::{Credential, Error};
|
use crate::{Credential, Error};
|
||||||
|
|
||||||
const DEFAULT_MAX_RESULTS: u32 = 10;
|
/// Default for the maximum number of results to return on a page
|
||||||
|
pub const DEFAULT_MAX_RESULTS: &str = "10";
|
||||||
|
|
||||||
/// Struct to capture configuration for List API call.
|
/// Struct to capture configuration for List API call.
|
||||||
pub struct List {
|
pub struct List {
|
||||||
@@ -50,10 +51,20 @@ impl List {
|
|||||||
|
|
||||||
Ok(List {
|
Ok(List {
|
||||||
hub: Gmail::new(client, auth),
|
hub: Gmail::new(client, auth),
|
||||||
max_results: DEFAULT_MAX_RESULTS,
|
max_results: DEFAULT_MAX_RESULTS.parse::<u32>().unwrap(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the maximum results
|
||||||
|
pub fn set_max_results(&mut self, value: u32) {
|
||||||
|
self.max_results = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Report the maximum results value
|
||||||
|
pub fn max_results(&self) -> u32 {
|
||||||
|
self.max_results
|
||||||
|
}
|
||||||
|
|
||||||
/// Run the Gmail api as configured
|
/// Run the Gmail api as configured
|
||||||
pub async fn run(&self) -> Result<(), Error> {
|
pub async fn run(&self) -> Result<(), Error> {
|
||||||
let (_response, list) = self
|
let (_response, list) = self
|
||||||
|
|||||||
Reference in New Issue
Block a user