Lines
69.23 %
Functions
66.67 %
Branches
100 %
use crate::render::{WireValue, parse_wire};
use nomiscript::Value;
use super::escape_str;
/// Build the nomiscript form for `(convert-amount num/denom from-uuid to-uuid)`.
pub fn build_convert_amount_form(amount_num_denom: &str, from: &str, to: &str) -> String {
format!(
"(convert-amount {} {} {})",
escape_str(amount_num_denom),
escape_str(from),
escape_str(to)
)
}
/// Parse a wire reply and return the value formatted as a string.
///
/// Used to surface query results (e.g. `convert-amount`) on the status line
/// without exposing `nomiscript::Value` to calling crates.
pub fn parse_scalar_reply(wire: &str) -> Result<String, String> {
let value = parse_wire(wire).map_err(|e| e.to_string())?;
let WireValue::Value(v) = value;
Ok(match v {
Value::String(s) => s,
other => nomiscript::format_value(&other),
})