pub fn to_string_value(value: &Value) -> Result<String>Expand description
Serialize a Value directly to a YAML String, preserving
Value::Tagged shape losslessly.
This function bypasses the Serialize pipeline entirely and writes
the YAML-tag prefix directly. to_string/to_value also preserve
Value::Tagged when T is (or contains) a Value — see the note on
to_value — but this one skips the round trip through Serializer
altogether.
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(_)));