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