pub fn to_slim_vec<T>(value: &T) -> Result<Vec<u8>>Expand description
Serialize a value using the Slim configuration and return a Vec<u8>.
This is a convenience function that creates a new Vec<u8> and calls serialize_slim on it.
It serializes without identifiers, using indices for enum variants.
ยงExample
use serde::{Serialize, Deserialize};
use postbag::to_slim_vec;
#[derive(Serialize, Deserialize)]
struct Person {
name: String,
age: u32,
}
let person = Person {
name: "Alice".to_string(),
age: 30,
};
let bytes = to_slim_vec(&person).unwrap();
println!("Serialized {} bytes", bytes.len());