-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:juspay/hyperswitch into rmove-backw…
…ards-compat
- Loading branch information
Showing
37 changed files
with
1,061 additions
and
293 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#![allow(missing_docs)] | ||
|
||
#[macro_export] | ||
macro_rules! newtype_impl { | ||
($is_pub:vis, $name:ident, $ty_path:path) => { | ||
impl std::ops::Deref for $name { | ||
type Target = $ty_path; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl std::ops::DerefMut for $name { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
impl From<$ty_path> for $name { | ||
fn from(ty: $ty_path) -> Self { | ||
Self(ty) | ||
} | ||
} | ||
|
||
impl $name { | ||
pub fn into_inner(self) -> $ty_path { | ||
self.0 | ||
} | ||
} | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! newtype { | ||
($is_pub:vis $name:ident = $ty_path:path) => { | ||
$is_pub struct $name(pub $ty_path); | ||
|
||
$crate::newtype_impl!($is_pub, $name, $ty_path); | ||
}; | ||
|
||
($is_pub:vis $name:ident = $ty_path:path, derives = ($($trt:path),*)) => { | ||
#[derive($($trt),*)] | ||
$is_pub struct $name(pub $ty_path); | ||
|
||
$crate::newtype_impl!($is_pub, $name, $ty_path); | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! async_spawn { | ||
($t:block) => { | ||
tokio::spawn(async move { $t }); | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! fallback_reverse_lookup_not_found { | ||
($a:expr,$b:expr) => { | ||
match $a { | ||
Ok(res) => res, | ||
Err(err) => { | ||
router_env::logger::error!(reverse_lookup_fallback = %err); | ||
match err.current_context() { | ||
errors::StorageError::ValueNotFound(_) => return $b, | ||
errors::StorageError::DatabaseError(data_err) => { | ||
match data_err.current_context() { | ||
diesel_models::errors::DatabaseError::NotFound => return $b, | ||
_ => return Err(err) | ||
} | ||
} | ||
_=> return Err(err) | ||
} | ||
} | ||
}; | ||
}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! collect_missing_value_keys { | ||
[$(($key:literal, $option:expr)),+] => { | ||
{ | ||
let mut keys: Vec<&'static str> = Vec::new(); | ||
$( | ||
if $option.is_none() { | ||
keys.push($key); | ||
} | ||
)* | ||
keys | ||
} | ||
}; | ||
} |
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
Oops, something went wrong.