tdlib_tl_parser/
errors.rs

1// Copyright 2020 - developers of the `grammers` project.
2// Copyright 2022 - developers of the `tdlib-rs` project.
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10//! Errors that can occur during the parsing of [Type Language] definitions.
11//!
12//! [Type Language]: https://core.telegram.org/mtproto/TL
13
14/// The error type for the parsing operation of [`Definition`]s.
15///
16/// [`Definition`]: tl/struct.Definition.html
17#[derive(Debug, PartialEq, Eq)]
18pub enum ParseError {
19    /// The definition is empty.
20    Empty,
21
22    /// One of the parameters from this definition was invalid.
23    InvalidParam(ParamParseError),
24
25    /// The name information is missing from the definition.
26    MissingName,
27
28    /// The type information is missing from the definition.
29    MissingType,
30
31    /// The parser does not know how to parse the definition.
32    NotImplemented,
33
34    /// The file contained an unknown separator (such as `---foo---`)
35    UnknownSeparator,
36}
37
38/// The error type for the parsing operation of [`Parameter`]s.
39///
40/// [`Parameter`]: tl/struct.Parameter.html
41#[derive(Debug, PartialEq, Eq)]
42pub enum ParamParseError {
43    /// The parameter was empty.
44    Empty,
45
46    /// The generic argument was invalid.
47    InvalidGeneric,
48
49    /// The parser does not know how to parse the parameter.
50    NotImplemented,
51}