1
use crate::render::{WireValue, parse_wire};
2
use nomiscript::Value;
3

            
4
/// Parse a wire reply and return the value formatted as a string.
5
///
6
/// Used to surface query results (e.g. `convert`) on the status line
7
/// without exposing `nomiscript::Value` to calling crates.
8
27
pub fn parse_scalar_reply(wire: &str) -> Result<String, String> {
9
27
    let value = parse_wire(wire).map_err(|e| e.to_string())?;
10
15
    let WireValue::Value(v) = value;
11
15
    Ok(match v {
12
1
        Value::String(s) => s,
13
14
        other => nomiscript::format_value_display(&other),
14
    })
15
27
}