Skip to main content

to_vec

Function to_vec 

Source
pub fn to_vec<T>(value: &T) -> Result<Vec<u8>, SerializeError>
where T: Facet<'static>,
Expand description

Serializes any Facet type to postcard bytes.

ยงExample

use facet::Facet;
use facet_postcard::to_vec;

#[derive(Debug, Facet)]
struct Point {
    x: i32,
    y: i32,
}

let point = Point { x: 10, y: 20 };
let bytes = to_vec(&point).unwrap();