Skip to content

Commit

Permalink
fix: Implement clippy suggestions and format code
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsvante committed Oct 24, 2021
1 parent 6125db7 commit 4725b45
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
6 changes: 5 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ pub fn run() -> Result<(), Error> {
let api = RestApi::new(&config);

match &opts.subcmd {
SubCommand::SuiteQl { query, limit, offset } => {
SubCommand::SuiteQl {
query,
limit,
offset,
} => {
let result = api.suiteql.raw(query, *limit, *offset)?;
println!("{}", result);
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#![doc = include_str!("../README.md")]
pub mod cli;
mod config;
mod requester;
mod params;
mod suiteql;
mod error;
pub mod oauth1;
mod params;
mod requester;
mod rest_api;
mod suiteql;

pub use config::*;
pub use error::*;
Expand Down
15 changes: 10 additions & 5 deletions src/params.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::collections::HashMap;


#[derive(Debug, Clone)]
pub struct Params<'a>(Vec<(&'a str, &'a str)>);

Expand All @@ -18,12 +17,18 @@ impl<'a> Params<'a> {
}
}

impl<'a> Into<HashMap<&'a str, &'a str>> for Params<'a> {
fn into(self) -> HashMap<&'a str, &'a str> {
let mut map = HashMap::with_capacity(self.0.len());
for (k, v) in self.0 {
impl<'a> From<Params<'a>> for HashMap<&'a str, &'a str> {
fn from(params: Params<'a>) -> Self {
let mut map = Self::with_capacity(params.0.len());
for (k, v) in params.0 {
map.insert(k, v);
}
map
}
}

impl<'a> Default for Params<'a> {
fn default() -> Self {
Self::new()
}
}
2 changes: 1 addition & 1 deletion src/requester.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::config::Config;
use crate::oauth1;
use crate::Error;
use crate::params::Params;
use crate::Error;
use http::Method;
use log::info;

Expand Down
5 changes: 2 additions & 3 deletions src/rest_api.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::config::Config;
use crate::suiteql::SuiteQl;
use crate::requester::Requester;
use crate::suiteql::SuiteQl;

static DEFAULT_BASE_URL: &'static str =
"https://{}.suitetalk.api.netsuite.com/services/rest/query/v1";
static DEFAULT_BASE_URL: &str = "https://{}.suitetalk.api.netsuite.com/services/rest/query/v1";

pub struct RestApi<'a> {
pub suiteql: SuiteQl<'a>,
Expand Down
13 changes: 9 additions & 4 deletions src/suiteql.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
use crate::error::Error;
use crate::requester::Requester;
use crate::params::Params;
use crate::requester::Requester;
use http::Method;

pub struct SuiteQl<'a> { requester: Requester<'a>, limit: usize }
pub struct SuiteQl<'a> {
requester: Requester<'a>,
limit: usize,
}

impl<'a> SuiteQl<'a> {

pub fn new(requester: Requester<'a>) -> Self {
Self { requester, limit: 1000 }
Self {
requester,
limit: 1000,
}
}

pub fn set_limit(&mut self, limit: usize) {
Expand Down

0 comments on commit 4725b45

Please sign in to comment.