#[macro_export]
macro_rules! cast_ref {
(($variable:expr) as $object:ident<$($traits:path),+>) => {{
(&$variable as &dyn std::any::Any)
.downcast_ref::<$object<$($traits),+>>()
.ok_or_else(|| anyhow!("Failed to downcast {}", stringify!($variable)))?
}};
($variable:ident as $object:ident<$($traits:path),+>) => {{
(&$variable as &dyn std::any::Any)
.downcast_ref::<$object<$($traits),+>>()
.ok_or_else(|| anyhow!("Failed to downcast {}", stringify!($variable)))?
}};
(&$variable:ident as $object:ident<$($traits:path),+>) => {{
($variable as &dyn std::any::Any)
.downcast_ref::<$object<$($traits),+>>()
.ok_or_else(|| anyhow!("Failed to downcast {}", stringify!($variable)))?
}};
}
#[macro_export]
macro_rules! process {
($self:ident, $logic:ident) => {{
match N::ID {
console::network::Testnet3::ID => {
$logic!($self.process.read(), console::network::Testnet3, circuit::AleoV0)
}
_ => Err(anyhow!("Unsupported VM configuration for network: {}", N::ID)),
}
}};
}
#[macro_export]
macro_rules! process_mut {
($self:ident, $logic:ident) => {{
match N::ID {
console::network::Testnet3::ID => {
$logic!($self.process.write(), console::network::Testnet3, circuit::AleoV0)
}
_ => Err(anyhow!("Unsupported VM configuration for network: {}", N::ID)),
}
}};
}