1
use std::collections::HashMap;
2

            
3
use serde::{Deserialize, Serialize};
4
use serde_bytes::ByteBuf;
5

            
6
16
#[derive(Serialize, Deserialize, Debug)]
7
struct ExampleStruct {
8
    integers: Vec<usize>,
9
    floats: Vec<f64>,
10
    bools: Vec<bool>,
11
    chars: Vec<char>,
12
    string: String,
13
    raw_string: String,
14
    bytes: Vec<u8>,
15
    byte_string: ByteBuf,
16
    raw_byte_string: ByteBuf,
17
    named_map: NamedExample,
18
    named_tuple: NamedExample,
19
    r#raw_identifiers: bool,
20
    array: Vec<usize>,
21
    tuple: Vec<usize>,
22
    map: HashMap<String, usize>,
23
}
24

            
25
6
#[derive(Serialize, Deserialize, Debug)]
26
enum NamedExample {
27
    StructLike { field: usize },
28
    TupleLike(usize),
29
}
30

            
31
1
fn main() {
32
1
    let example: ExampleStruct =
33
1
        rsn::from_str(include_str!("./alltypes.rsn")).expect("error deserializing alltypes.rsn");
34
1

            
35
1
    println!("Loaded blog posts: {example:?}");
36
1
}
37

            
38
#[test]
39
1
fn runs() {
40
1
    main();
41
1
}