chore: address Rust 1.77 clippy lints (#4172)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
This commit is contained in:
Chethan Rao
2024-03-22 18:22:18 +05:30
committed by GitHub
parent 4c8cdf1475
commit f213c51b3e
16 changed files with 46 additions and 105 deletions

View File

@ -35,9 +35,6 @@ pub mod date_time {
},
OffsetDateTime, PrimitiveDateTime,
};
/// Struct to represent milliseconds in time sensitive data fields
#[derive(Debug)]
pub struct Milliseconds(i32);
/// Enum to represent date formats
#[derive(Debug)]

View File

@ -1,10 +1,6 @@
use masking::{Maskable, Secret};
#[cfg(feature = "logs")]
use router_env::logger;
use serde::{Deserialize, Serialize};
use crate::errors;
pub type Headers = std::collections::HashSet<(String, Maskable<String>)>;
#[derive(
@ -64,6 +60,18 @@ pub enum RequestContent {
RawBytes(Vec<u8>),
}
impl RequestContent {
pub fn get_inner_value(&self) -> Secret<String> {
match self {
Self::Json(i) => serde_json::to_string(&i).unwrap_or_default().into(),
Self::FormUrlEncoded(i) => serde_urlencoded::to_string(i).unwrap_or_default().into(),
Self::Xml(i) => quick_xml::se::to_string(&i).unwrap_or_default().into(),
Self::FormData(_) => String::new().into(),
Self::RawBytes(_) => String::new().into(),
}
}
}
impl Request {
pub fn new(method: Method, url: &str) -> Self {
Self {
@ -176,33 +184,3 @@ impl Default for RequestBuilder {
Self::new()
}
}
#[derive(Clone, Debug)]
pub struct RequestBody(Secret<String>);
impl RequestBody {
pub fn log_and_get_request_body<T, F>(
body: T,
encoder: F,
) -> errors::CustomResult<Self, errors::ParsingError>
where
F: FnOnce(T) -> errors::CustomResult<String, errors::ParsingError>,
T: std::fmt::Debug,
{
#[cfg(feature = "logs")]
logger::info!(connector_request_body=?body);
Ok(Self(Secret::new(encoder(body)?)))
}
pub fn get_inner_value(request_body: RequestContent) -> Secret<String> {
match request_body {
RequestContent::Json(i) => serde_json::to_string(&i).unwrap_or_default().into(),
RequestContent::FormUrlEncoded(i) => {
serde_urlencoded::to_string(&i).unwrap_or_default().into()
}
RequestContent::Xml(i) => quick_xml::se::to_string(&i).unwrap_or_default().into(),
RequestContent::FormData(_) => String::new().into(),
RequestContent::RawBytes(_) => String::new().into(),
}
}
}