#[macro_export]
macro_rules! cfg_client {
($($item:item)*) => {
$(
#[cfg_attr(doc_cfg, doc(cfg(feature = "client")))]
#[cfg(feature = "client")]
$item
)*
};
}
#[macro_export]
macro_rules! cfg_program {
($($item:item)*) => {
$(
#[cfg_attr(doc_cfg, doc(cfg(not(feature = "client"))))]
#[cfg(not(feature = "client"))]
$item
)*
};
}
#[macro_export]
macro_rules! cfg_secrets {
($($item:item)*) => {
$(
#[cfg(all(feature = "secrets", not(target_os = "solana")))]
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "secrets", not(target_os = "solana")))))]
$item
)*
};
}
#[macro_export]
macro_rules! cfg_macros {
($($item:item)*) => {
$(
#[cfg(all(feature = "macros", not(target_os = "solana")))]
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "macros", not(target_os = "solana")))))]
$item
)*
};
}
#[macro_export]
macro_rules! cfg_ipfs {
($($item:item)*) => {
$(
#[cfg(all(feature = "ipfs", not(target_os = "solana")))]
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "ipfs", not(target_os = "solana")))))]
$item
)*
};
}
#[cfg(not(target_os = "solana"))]
#[cfg_attr(doc_cfg, doc(cfg(not(target_os = "solana"))))]
#[macro_export]
macro_rules! retry {
($attempts:expr, $delay_ms:expr, $expr:expr) => {{
async {
let mut attempts = $attempts;
loop {
match $expr {
Ok(val) => break Ok(val),
Err(_) if attempts > 1 => {
attempts -= 1;
tokio::time::sleep(tokio::time::Duration::from_millis($delay_ms)).await;
}
Err(e) => break Err(e),
}
}
}
}};
}
#[cfg(not(target_os = "solana"))]
#[cfg_attr(doc_cfg, doc(cfg(not(target_os = "solana"))))]
#[macro_export]
macro_rules! blocking_retry {
($attempts:expr, $delay_ms:expr, $expr:expr) => {{
let mut attempts = $attempts;
loop {
match $expr {
Ok(val) => break Ok(val),
Err(_) if attempts > 1 => {
attempts -= 1;
std::thread::sleep(tokio::time::Duration::from_millis($delay_ms));
}
Err(e) => break Err(e),
}
}
}};
}