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
pub mod inline_table;
pub mod keyval;
pub mod val;

use crate::model::{
    layer210::{BasicString, Key, LiteralString, LiteralValue},
    layer220::Array,
};

/// It has a key and a value.  

/// キーと値を持ちます。  

#[derive(Clone)]
pub struct Keyval {
    pub key: Box<Key>,
    /// Right value. Recursive.

    /// 右値。 再帰的。

    pub val: Box<Val>,
}

/// The right side of the key value model.  

/// キー値モデルの右辺です。  

#[derive(Clone)]
pub enum Val {
    /// Recursive.

    /// 再帰的。

    Array(Array),
    BasicString(BasicString),
    /// Recursive.

    /// 再帰的。

    InlineTable(InlineTable),
    // No Keyval.

    LiteralValue(LiteralValue),
    LiteralString(LiteralString),
}

/// It has multiple key-values.  

/// 複数の キー・バリュー を持ちます。  

#[derive(Clone)]
pub struct InlineTable {
    items: Vec<Keyval>,
}