umari 0.0.1

SDK for building event-sourced WASM components for the Umari runtime
Documentation
/// Convenience macro for emitting multiple events.
///
/// # Example
///
/// ```rust,ignore
/// fn handle(self, input: Input) -> Result<Emit, CommandError> {
///     Ok(emit![
///         SentFunds {
///             account_id: input.source_account,
///             amount: input.amount,
///             recipient_id: Some(input.dest_account.clone()),
///         },
///         ReceivedFunds {
///             account_id: input.dest_account,
///             amount: input.amount,
///             sender_id: Some(input.source_account),
///         },
///     ])
/// }
/// ```
///
/// Expands to:
///
/// ```rust,ignore
/// Emit::new()
///     .event(SentFunds { ... })
///     .event(ReceivedFunds { ... })
/// ```
#[macro_export]
macro_rules! emit {
    () => {
        $crate::emit::Emit::new()
    };
    ($($event:expr),+ $(,)?) => {
        $crate::emit::Emit::new()
            $(.event($event))+
    };
}

#[macro_export]
macro_rules! reject {
    ($s:literal, $($t:tt)*) => {{
        return Err($crate::error::CommandError::reject(format!($s, $($t)*)))
    }};
    ($e:expr) => {{
        return Err($crate::error::CommandError::reject($e.to_string()))
    }};
}