pub fn to_string_value(value: &Value) -> Result<String>Expand description
Serialize a Value directly to a YAML String, preserving
Value::Tagged shape losslessly.
Going through the generic to_string<T: Serialize> path
routes Value::Tagged(...) through Serializer::serialize_map
(which emits a single-entry mapping for serde-bridge interop),
which loses the YAML-tag wire form. This function bypasses the
Serialize pipeline and writes the YAML-tag prefix directly.
Use this whenever you hold a Value that may contain
Value::Tagged and want the emitted YAML to round-trip back
into an equivalent Value::Tagged.
§Errors
All variants documented on to_string.
§Examples
use noyalib::{from_str, to_string_value, Value};
let v: Value = from_str("!Color '#ff8800'\n").unwrap();
assert!(matches!(v, Value::Tagged(_)));
let s = to_string_value(&v).unwrap();
// Re-parsing yields an equivalent `Value::Tagged`.
let back: Value = from_str(&s).unwrap();
assert!(matches!(back, Value::Tagged(_)));