use serde_json::Value;
use crate::error::ImError;
use crate::outbound::registry::{OutboundCommand, OutboundRegistration};
macro_rules! chain_command {
($ty:ident, $name:literal) => {
struct $ty;
impl OutboundCommand for $ty {
fn name(&self) -> &'static str {
$name
}
fn build(&self, args: &Value) -> Result<(&'static str, Value), ImError> {
crate::chain::wire_body($name, args)
}
fn is_read(&self) -> bool {
$name == "post_chain_get"
}
}
inventory::submit! {
OutboundRegistration {
name: $name,
command: &$ty,
}
}
};
}
chain_command!(CreateChainCommand, "post_chain_create");
chain_command!(UpdateChainDraftCommand, "post_chain_update_draft");
chain_command!(PublishChainCommand, "post_chain_publish");
chain_command!(AppendChainCommand, "post_chain_append");
chain_command!(GetChainCommand, "post_chain_get");
chain_command!(ReconcileChainCommand, "post_chain_reconcile");
chain_command!(CloseChainCommand, "post_chain_close");
chain_command!(RetractChainCommand, "post_chain_retract");
chain_command!(MarkChainReadCommand, "post_chain_mark_read");