-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e01c54
commit 42d4038
Showing
12 changed files
with
393 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ mod metadata; | |
pub mod oauth1; | ||
mod params; | ||
mod requester; | ||
mod response; | ||
mod rest_api; | ||
mod suiteql; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,47 @@ | ||
use std::collections::HashMap; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct Params<'a>(Vec<(&'a str, &'a str)>); | ||
pub struct Params(Vec<(String, String)>); | ||
|
||
impl<'a> Params<'a> { | ||
impl Params { | ||
pub fn new() -> Self { | ||
Self(Vec::new()) | ||
} | ||
|
||
pub fn push(&mut self, k: &'a str, v: &'a str) { | ||
pub fn push(&mut self, k: String, v: String) { | ||
self.0.push((k, v)) | ||
} | ||
|
||
pub fn get(&self) -> &Vec<(&'a str, &'a str)> { | ||
pub fn get(&self) -> &Vec<(String, String)> { | ||
&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 From<Params> for Vec<(String, String)> { | ||
fn from(params: Params) -> Self { | ||
params.0 | ||
} | ||
} | ||
|
||
impl<'a> Default for Params<'a> { | ||
impl Default for Params { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct ParamStr(String, String); | ||
|
||
impl ParamStr { | ||
pub(crate) fn new(k: String, v: String) -> Self { | ||
Self(k, v) | ||
} | ||
} | ||
|
||
impl From<Vec<ParamStr>> for Params { | ||
fn from(param_strings: Vec<ParamStr>) -> Self { | ||
let mut p = Params::new(); | ||
for ps in param_strings { | ||
p.push(ps.0, ps.1); | ||
} | ||
p | ||
} | ||
} |
Oops, something went wrong.