mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
refactor(router): move fp_utils module to common_utils crate (#391)
Co-authored-by: Arun Raj M <jarnura47@gmail.com> Co-authored-by: Nishant Joshi <nishant.joshi@juspay.in>
This commit is contained in:
@ -1,6 +1,13 @@
|
||||
//! Functional programming utilities
|
||||
|
||||
/// The Applicative trait provides a pure behavior,
|
||||
/// which can be used to create values of type f a from values of type a.
|
||||
pub trait Applicative<R> {
|
||||
/// The Associative type acts as a (f a) wrapper for Self.
|
||||
type WrappedSelf<T>;
|
||||
|
||||
/// Applicative::pure(_) is abstraction with lifts any arbitrary type to underlying higher
|
||||
/// order type
|
||||
fn pure(v: R) -> Self::WrappedSelf<R>;
|
||||
}
|
||||
|
||||
@ -18,7 +25,8 @@ impl<R, E> Applicative<R> for Result<R, E> {
|
||||
}
|
||||
}
|
||||
|
||||
// This function allows lazy evaluation of the `f` argument
|
||||
/// This function wraps the evaluated result of `f` into current context,
|
||||
/// based on the condition provided into the `predicate`
|
||||
pub fn when<W: Applicative<(), WrappedSelf<()> = W>, F>(predicate: bool, f: F) -> W
|
||||
where
|
||||
F: FnOnce() -> W,
|
||||
@ -7,6 +7,7 @@ pub mod crypto;
|
||||
pub mod custom_serde;
|
||||
pub mod errors;
|
||||
pub mod ext_traits;
|
||||
pub mod fp_utils;
|
||||
pub mod pii;
|
||||
pub mod validation;
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
pub(crate) mod custom_serde;
|
||||
pub(crate) mod db_utils;
|
||||
mod ext_traits;
|
||||
mod fp_utils;
|
||||
|
||||
#[cfg(feature = "kv_store")]
|
||||
pub(crate) mod storage_partitioning;
|
||||
@ -9,14 +8,12 @@ pub(crate) mod storage_partitioning;
|
||||
pub(crate) use common_utils::{
|
||||
crypto,
|
||||
ext_traits::{ByteSliceExt, BytesExt, Encode, StringExt, ValueExt},
|
||||
fp_utils::when,
|
||||
validation::validate_email,
|
||||
};
|
||||
use nanoid::nanoid;
|
||||
|
||||
pub(crate) use self::{
|
||||
ext_traits::{OptionExt, ValidateCall},
|
||||
fp_utils::when,
|
||||
};
|
||||
pub(crate) use self::ext_traits::{OptionExt, ValidateCall};
|
||||
use crate::consts;
|
||||
|
||||
pub mod error_parser {
|
||||
|
||||
Reference in New Issue
Block a user