use super::net_handle;
pub(crate) mod ops {
use std::time::Duration;
use serde_json::Value;
use crate::error::Result;
use crate::wire::{net_command, CommandResponse, Op, Timeout};
fn parse_value(resp: CommandResponse) -> Result<Value> {
Ok(resp.value.unwrap_or(Value::Null))
}
pub(crate) fn command(name: &str, action: &str, params: Value) -> Op<Value> {
Op {
req: net_command(
name,
None,
action,
params,
Timeout::After(Duration::from_secs(120)),
),
parse: parse_value,
}
}
}
net_handle! {
sync: CustomNet,
async: AsyncCustomNet,
methods: {
fn command(action: &str, params: serde_json::Value) -> serde_json::Value = ops::command;
}
}