chore(router): clippy::use_self (#203)

This commit is contained in:
kos-for-juspay
2022-12-22 06:50:53 +01:00
committed by GitHub
parent 939827da8f
commit e044451a4b
28 changed files with 336 additions and 380 deletions

View File

@ -42,8 +42,8 @@ pub struct Request {
}
impl Request {
pub fn new(method: Method, url: &str) -> Request {
Request {
pub fn new(method: Method, url: &str) -> Self {
Self {
method,
url: String::from(url),
headers: Vec::new(),
@ -87,8 +87,8 @@ pub struct RequestBuilder {
}
impl RequestBuilder {
pub fn new() -> RequestBuilder {
RequestBuilder {
pub fn new() -> Self {
Self {
method: Method::Get,
url: String::with_capacity(1024),
headers: Vec::new(),
@ -99,44 +99,44 @@ impl RequestBuilder {
}
}
pub fn url(mut self, url: &str) -> RequestBuilder {
pub fn url(mut self, url: &str) -> Self {
self.url = url.into();
self
}
pub fn method(mut self, method: Method) -> RequestBuilder {
pub fn method(mut self, method: Method) -> Self {
self.method = method;
self
}
pub fn header(mut self, header: &str, value: &str) -> RequestBuilder {
pub fn header(mut self, header: &str, value: &str) -> Self {
self.headers.push((header.into(), value.into()));
self
}
pub fn headers(mut self, headers: Vec<(String, String)>) -> RequestBuilder {
pub fn headers(mut self, headers: Vec<(String, String)>) -> Self {
// Fixme add union property
let mut h = headers.into_iter().map(|(h, v)| (h, v)).collect();
self.headers.append(&mut h);
self
}
pub fn body(mut self, body: Option<String>) -> RequestBuilder {
pub fn body(mut self, body: Option<String>) -> Self {
self.payload = body.map(From::from);
self
}
pub fn content_type(mut self, content_type: ContentType) -> RequestBuilder {
pub fn content_type(mut self, content_type: ContentType) -> Self {
self.content_type = Some(content_type);
self
}
pub fn add_certificate(mut self, certificate: Option<String>) -> RequestBuilder {
pub fn add_certificate(mut self, certificate: Option<String>) -> Self {
self.certificate = certificate;
self
}
pub fn add_certificate_key(mut self, certificate_key: Option<String>) -> RequestBuilder {
pub fn add_certificate_key(mut self, certificate_key: Option<String>) -> Self {
self.certificate_key = certificate_key;
self
}