pub fn to_string_with_config<T>(
value: &T,
config: &SerializerConfig,
) -> Result<String>Expand description
Serialize a Rust value to a YAML String with a custom
SerializerConfig.
§Errors
Same variant set as to_string. The active config
controls which limit-related errors can fire — in particular,
raising max_depth lets deeper graphs through, lowering it
surfaces Error::DepthLimit sooner.
§Examples
use noyalib::SerializerConfig;
#[derive(serde::Serialize)]
struct Config {
name: String,
port: u16,
}
let config = Config {
name: "myapp".to_string(),
port: 8080,
};
let yaml = noyalib::to_string_with_config(
&config,
&SerializerConfig::new().indent(4).document_start(true),
)
.unwrap();
assert!(yaml.starts_with("---"));