libyaml_safer/
token.rs

1use crate::{Encoding, Mark, ScalarStyle};
2
3/// The token structure.
4#[derive(Debug, PartialEq)]
5#[non_exhaustive]
6pub struct Token {
7    /// The token type.
8    pub data: TokenData,
9    /// The beginning of the token.
10    pub start_mark: Mark,
11    /// The end of the token.
12    pub end_mark: Mark,
13}
14
15#[derive(Debug, PartialEq)]
16pub enum TokenData {
17    /// A STREAM-START token.
18    StreamStart {
19        /// The stream encoding.
20        encoding: Encoding,
21    },
22    /// A STREAM-END token.
23    StreamEnd,
24    /// A VERSION-DIRECTIVE token.
25    VersionDirective {
26        /// The major version number.
27        major: i32,
28        /// The minor version number.
29        minor: i32,
30    },
31    /// A TAG-DIRECTIVE token.
32    TagDirective {
33        /// The tag handle.
34        handle: String,
35        /// The tag prefix.
36        prefix: String,
37    },
38    /// A DOCUMENT-START token.
39    DocumentStart,
40    /// A DOCUMENT-END token.
41    DocumentEnd,
42    /// A BLOCK-SEQUENCE-START token.
43    BlockSequenceStart,
44    /// A BLOCK-MAPPING-START token.
45    BlockMappingStart,
46    /// A BLOCK-END token.
47    BlockEnd,
48    /// A FLOW-SEQUENCE-START token.
49    FlowSequenceStart,
50    /// A FLOW-SEQUENCE-END token.
51    FlowSequenceEnd,
52    /// A FLOW-MAPPING-START token.
53    FlowMappingStart,
54    /// A FLOW-MAPPING-END token.
55    FlowMappingEnd,
56    /// A BLOCK-ENTRY token.
57    BlockEntry,
58    /// A FLOW-ENTRY token.
59    FlowEntry,
60    /// A KEY token.
61    Key,
62    /// A VALUE token.
63    Value,
64    /// An ALIAS token.
65    Alias {
66        /// The alias value.
67        value: String,
68    },
69    /// An ANCHOR token.
70    Anchor {
71        /// The anchor value.
72        value: String,
73    },
74    /// A TAG token.
75    Tag {
76        /// The tag handle.
77        handle: String,
78        /// The tag suffix.
79        suffix: String,
80    },
81    /// A SCALAR token.
82    Scalar {
83        /// The scalar value.
84        value: String,
85        /// The scalar style.
86        style: ScalarStyle,
87    },
88}