[][src]Function polyglot::to_vec

pub fn to_vec<T: Serialize>(val: &T, format: Format) -> Result<Vec<u8>>

Serialize a struct in the given format, outputting a vector of bytes.

Obviously, only formats enabled with feature flags will be supported.

Example

use polyglot::{ser, Format};
use serde::Serialize;

#[derive(Serialize)]
pub struct Person {
    pub name: String
}

let p = Person{name: String::from("John")};
let out_bytes = ser::to_vec(&p, Format::TOML).unwrap();