use serde_json::Value;
use crate::category_chain::wire;
use crate::error::ImError;
use crate::outbound::registry::{OutboundCommand, OutboundRegistration};
macro_rules! category_command {
($type:ident, $name:literal) => {
struct $type;
impl OutboundCommand for $type {
fn name(&self) -> &'static str {
$name
}
fn build(&self, args: &Value) -> Result<(&'static str, Value), ImError> {
wire::wire_body($name, args)
}
fn is_read(&self) -> bool {
crate::category_chain::is_read($name)
}
}
inventory::submit! {
OutboundRegistration {
name: $name,
command: &$type,
}
}
};
}
category_command!(
CategoryChainCreateDraftCommand,
"category_chain_create_draft"
);
category_command!(
CategoryChainUpdateDraftCommand,
"category_chain_update_draft"
);
category_command!(CategoryChainPublishCommand, "category_chain_publish");
category_command!(CategoryChainGetCommand, "category_chain_get");
category_command!(CategoryChainGetMineCommand, "category_chain_get_mine");
category_command!(
CategoryChainSetParticipationCommand,
"category_chain_set_participation"
);
category_command!(CategoryChainEntriesCommand, "category_chain_entries");
category_command!(CategoryChainCloseCommand, "category_chain_close");
category_command!(CategoryChainRetractCommand, "category_chain_retract");
category_command!(CategoryChainReconcileCommand, "category_chain_reconcile");
category_command!(
CategoryChainCapabilitiesCommand,
"category_chain_capabilities"
);