pub trait SYMLSerialize {
// Required method
fn serialize_min<F: FnMut(Arguments<'_>)>(&self, f: &mut F);
// Provided methods
fn serialize<F: FnMut(Arguments<'_>)>(&self, f: &mut F, indent: usize) { ... }
fn serialize_to_string(&self, indent: usize) -> String { ... }
fn serialize_min_to_string(&self) -> String { ... }
}
Required Methods§
Sourcefn serialize_min<F: FnMut(Arguments<'_>)>(&self, f: &mut F)
fn serialize_min<F: FnMut(Arguments<'_>)>(&self, f: &mut F)
Serialize to a shorter form
§Examples
let value = Value::from([
"2".into(),
Value::from(["3", "4", "5"]),
[("x", "6")].into()
]);
let mut buf = String::new();
value.serialize_min(&mut |args| write!(buf, "{args}").unwrap());
assert_eq!(&buf, "[2,[3,4,5],{x:6}]");
Provided Methods§
Sourcefn serialize<F: FnMut(Arguments<'_>)>(&self, f: &mut F, indent: usize)
fn serialize<F: FnMut(Arguments<'_>)>(&self, f: &mut F, indent: usize)
Serialize to standard form
§Examples
let value = Value::from([
"2".into(),
Value::from(["3", "4", "5"]),
[("x", "6")].into()
]);
let mut buf = String::new();
value.serialize(&mut |args| write!(buf, "{args}").unwrap(), 0);
buf.push('\n');
assert_eq!(&buf, "\
- 2
- - 3
- 4
- 5
- x: 6
");
Sourcefn serialize_to_string(&self, indent: usize) -> String
fn serialize_to_string(&self, indent: usize) -> String
Same as serialize, but collect to string
§Examples
let value = Value::from([
"2".into(),
Value::from(["3", "4", "5"]),
[("x", "6")].into()
]);
let mut buf = String::new();
value.serialize(&mut |args| write!(buf, "{args}").unwrap(), 0);
assert_eq!(buf, value.serialize_to_string(0));
Sourcefn serialize_min_to_string(&self) -> String
fn serialize_min_to_string(&self) -> String
Same as serialize_min, but collect to string
§Examples
let value = Value::from([
"2".into(),
Value::from(["3", "4", "5"]),
[("x", "6")].into()
]);
let mut buf = String::new();
value.serialize_min(&mut |args| write!(buf, "{args}").unwrap());
assert_eq!(buf, value.serialize_min_to_string());
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.