mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
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:
@ -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)]
|
||||
|
||||
@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user