tl_build/parser/errors.rs
1//! Errors that can occur during the parsing of [Type Language] definitions.
2//!
3//! [Type Language]: https://core.telegram.org/mtproto/TL
4use std::num::ParseIntError;
5
6/// The error type for the parsing operation of [`Definition`]s.
7///
8/// [`Definition`]: tl/struct.Definition.html
9#[derive(Debug, PartialEq)]
10pub enum ParseError {
11 /// The definition is empty.
12 Empty,
13
14 /// The identifier from this definition is invalid.
15 InvalidId(ParseIntError),
16
17 /// One of the parameters from this definition was invalid.
18 InvalidParam(ParamParseError),
19
20 /// The name information is missing from the definition.
21 MissingName,
22
23 /// The type information is missing from the definition.
24 MissingType,
25
26 /// The parser does not know how to parse the definition.
27 NotImplemented,
28
29 /// The file contained an unknown separator (such as `---foo---`)
30 UnknownSeparator,
31}
32
33/// The error type for the parsing operation of [`Parameter`]s.
34///
35/// [`Parameter`]: tl/struct.Parameter.html
36#[derive(Debug, PartialEq)]
37pub enum ParamParseError {
38 /// The parameter was empty.
39 Empty,
40
41 /// The flag specification was invalid.
42 InvalidFlag,
43
44 /// The generic argument was invalid.
45 InvalidGeneric,
46
47 /// The parameter is actually a generic type definition for later
48 /// use, such as `{X:Type}`, but it is not a parameter in itself.
49 TypeDef { name: String },
50
51 /// The parameter refers to some unknown definition.
52 MissingDef,
53
54 /// The parser does not know how to parse the parameter.
55 NotImplemented,
56}