1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! 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);
//! ```
pub use Error;
use ;
use Serialize;
/// Deserialize a sequence of records from a SIF string.
///
/// This function parses the SIF text and deserializes the result in one step.
/// The deserialized type must be `DeserializeOwned` (no borrowed data) since
/// the parsed document is an intermediate owned value.
/// Deserialize from a pre-parsed SIF document.
///
/// Use this when you already have a parsed `Document` and want to avoid
/// re-parsing. The deserialized type may borrow from the document.
/// Serialize a value to a SIF string.
/// Serialize a value as SIF into a writer.