Skip to content

Commit

Permalink
address some 'nursery' lints (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades authored Jan 19, 2022
1 parent 713cc91 commit 2919d9e
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ where
/// # }
pub async fn accounts(&self) -> Result<Vec<accounts::Account>> {
#[derive(Deserialize)]
pub(crate) struct Response {
pub struct Response {
accounts: Vec<accounts::Account>,
}
let response: Response = handle_request(&self.inner_client, &accounts::List).await?;
Expand Down
6 changes: 3 additions & 3 deletions src/client/inner/refreshable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ impl Client<Refreshable> {

/// Get a reference to the client id
#[must_use]
pub fn client_id(&self) -> &String {
pub const fn client_id(&self) -> &String {
&self.inner_client.client_id
}

/// Get a reference to the client secret
#[must_use]
pub fn client_secret(&self) -> &String {
pub const fn client_secret(&self) -> &String {
&self.inner_client.client_secret
}

/// Get a reference to the refresh token
#[must_use]
pub fn refresh_token(&self) -> &String {
pub const fn refresh_token(&self) -> &String {
&self.inner_client.refresh_token
}

Expand Down
2 changes: 1 addition & 1 deletion src/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod feed_items;
pub mod pots;
pub mod transactions;
mod utils;
pub(crate) mod who_am_i;
pub mod who_am_i;

pub trait Endpoint: Sync {
fn method(&self) -> reqwest::Method;
Expand Down
4 changes: 2 additions & 2 deletions src/endpoints/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod refresh {
}

impl<'a> Request<'a> {
pub(crate) fn new(
pub(crate) const fn new(
client_id: &'a str,
client_secret: &'a str,
refresh_token: &'a str,
Expand Down Expand Up @@ -76,7 +76,7 @@ mod refresh {
}

impl<'a> Form<'a> {
fn new(client_id: &'a str, client_secret: &'a str, refresh_token: &'a str) -> Self {
const fn new(client_id: &'a str, client_secret: &'a str, refresh_token: &'a str) -> Self {
Self {
grant_type: "refresh_token",
client_id,
Expand Down
4 changes: 2 additions & 2 deletions src/endpoints/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct Balance {
pub spend_today: i64,
}

pub(crate) use get::Request as Get;
pub use get::Request as Get;
mod get {
use serde::Serialize;

Expand All @@ -33,7 +33,7 @@ mod get {
}

impl<'a> Request<'a> {
pub(crate) fn new(account_id: &'a str) -> Self {
pub(crate) const fn new(account_id: &'a str) -> Self {
let query = Query { account_id };
Self { query }
}
Expand Down
14 changes: 7 additions & 7 deletions src/endpoints/feed_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ pub(crate) mod basic {
///
/// This is the url the user will be redirected to after
/// tapping on the feed item
pub fn url(mut self, url: &'a str) -> Self {
pub const fn url(mut self, url: &'a str) -> Self {
self.payload.url = Some(url);
self
}

/// Set the title of the feed item.
pub fn title(mut self, title: &'a str) -> Self {
pub const fn title(mut self, title: &'a str) -> Self {
self.payload.params.title = title;
self
}
Expand All @@ -65,31 +65,31 @@ pub(crate) mod basic {
///
/// # Note
/// *This doesn't currently seem to do anything*
pub fn image_url(mut self, image_url: &'a str) -> Self {
pub const fn image_url(mut self, image_url: &'a str) -> Self {
self.payload.params.image_url = image_url;
self
}

/// Set the background colour of the feed item
pub fn background_color(mut self, background_color: &'a str) -> Self {
pub const fn background_color(mut self, background_color: &'a str) -> Self {
self.payload.params.background_color = Some(background_color);
self
}

/// Set the body colour of the feed item
pub fn body_color(mut self, body_color: &'a str) -> Self {
pub const fn body_color(mut self, body_color: &'a str) -> Self {
self.payload.params.body_color = Some(body_color);
self
}

/// Set the title colour of the feed item
pub fn title_color(mut self, title_color: &'a str) -> Self {
pub const fn title_color(mut self, title_color: &'a str) -> Self {
self.payload.params.title_color = Some(title_color);
self
}

/// Set the body text of the feed item
pub fn body(mut self, body: &'a str) -> Self {
pub const fn body(mut self, body: &'a str) -> Self {
self.payload.params.body = Some(body);
self
}
Expand Down
6 changes: 3 additions & 3 deletions src/endpoints/pots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use serde::Deserialize;
use crate::endpoints::utils::empty_string_as_none;

mod list;
pub(crate) use list::Request as List;
pub use list::Request as List;
mod deposit;
pub(crate) use deposit::Request as Deposit;
pub use deposit::Request as Deposit;
mod withdraw;
pub(crate) use withdraw::Request as Withdraw;
pub use withdraw::Request as Withdraw;

/// Representation of a Monzo pot
#[derive(Deserialize, Debug, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/pots/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Request<'a> {
}

impl<'a> Request<'a> {
pub(crate) fn new(current_account_id: &'a str) -> Self {
pub(crate) const fn new(current_account_id: &'a str) -> Self {
let query = Query { current_account_id };
Self { query }
}
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/transactions/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<'a> Request<'a> {

/// Optionally expand the merchant field from an id string into a struct
/// container merchant details
pub fn expand_merchant(mut self) -> Self {
pub const fn expand_merchant(mut self) -> Self {
self.expand_merchant = true;
self
}
Expand Down
10 changes: 5 additions & 5 deletions src/endpoints/transactions/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ impl<'a> Request<'a> {
}

/// Only return transactions which occurred before a given `DateTime`
pub fn before(mut self, datetime: DateTime<Utc>) -> Self {
pub const fn before(mut self, datetime: DateTime<Utc>) -> Self {
self.query.pagination.before = Some(datetime);
self
}

/// Set the maximum number of transactions to be returned
pub fn limit(mut self, limit: u16) -> Self {
pub const fn limit(mut self, limit: u16) -> Self {
self.query.pagination.limit = Some(limit);
self
}

/// Optionally expand the merchant field from an id string into a struct
/// container merchant details
pub fn expand_merchant(mut self) -> Self {
pub const fn expand_merchant(mut self) -> Self {
self.query.expand_merchant = Some("merchant");
self
}
Expand Down Expand Up @@ -101,8 +101,8 @@ struct Query<'a> {
expand_merchant: Option<&'a str>,
}

#[derive(Deserialize)]
pub(crate) struct Response {
#[derive(Deserialize, Debug)]
pub struct Response {
transactions: Vec<Transaction>,
}

Expand Down

0 comments on commit 2919d9e

Please # to comment.