Skip to main content

Crate forma_sif

Crate forma_sif 

Source
Expand description

SIF serialization and deserialization for the Forma framework.

§Quick start

use forma_sif::{from_str, to_string};
use forma_derive::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug, PartialEq)]
struct Row {
    id: u64,
    name: String,
    active: bool,
}

// Serialize
let rows = vec![
    Row { id: 1, name: "alice".into(), active: true },
    Row { id: 2, name: "bob".into(), active: false },
];
let sif = to_string(&rows).unwrap();
assert!(sif.contains("#schema"));

// Deserialize
let back: Vec<Row> = from_str(&sif).unwrap();
assert_eq!(back, rows);

Re-exports§

pub use error::Error;

Modules§

de
error
ser

Functions§

from_document
Deserialize from a pre-parsed SIF document.
from_str
Deserialize a sequence of records from a SIF string.
to_string
Serialize a value to a SIF string.
to_writer
Serialize a value as SIF into a writer.