Skip to main content

Module options

Module options 

Source
Expand description

Serializer options for YAML emission.

Controls indentation and optional anchor name generation for the serializer.

Example: use 4-space indentation and a custom anchor naming scheme.

use serde::Serialize;

#[derive(Serialize)]
struct Item { a: i32, b: bool }

let mut buf = String::new();
let opts = serde_saphyr::ser_options! {
    indent_step: 4,
    anchor_generator: Some(|id| format!("id{}/", id)),
};
serde_saphyr::to_fmt_writer_with_options(&mut buf, &Item { a: 1, b: true }, opts).unwrap();
assert!(buf.contains("a: 1"));

Structsยง

SerializerOptions
Serializer options for YAML emission.