Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 // Copyright 2020 - developers of the `grammers` project.
2 // Copyright 2021 - 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 //! This library provides a public interface to parse [Type Language]
12 //! definitions.
13 //!
14 //! It exports a single public method, [`parse_tl_file`] to parse entire
15 //! `.tl` files and yield the definitions it contains. This method will
16 //! yield [`Definition`]s containing all the information you would possibly
17 //! need to later use somewhere else (for example, to generate code).
18 //!
19 //! [Type Language]: https://core.telegram.org/mtproto/TL
20 //! [`parse_tl_file`]: fn.parse_tl_file.html
21 //! [`Definition`]: tl/struct.Definition.html
22 pub mod errorsrust-analyzer cargo tdlib-rs-parser 1.4.0 errors/;
23 pub mod tlrust-analyzer cargo tdlib-rs-parser 1.4.0 tl/;
24 mod tl_iteratorrust-analyzer cargo tdlib-rs-parser 1.4.0 tl_iterator/;
25
26 use errorsrust-analyzer cargo tdlib-rs-parser 1.4.0 errors/::ParseErrorrust-analyzer cargo tdlib-rs-parser 1.4.0 errors/ParseError#;
27 use tlrust-analyzer cargo tdlib-rs-parser 1.4.0 tl/::Definitionrust-analyzer cargo tdlib-rs-parser 1.4.0 tl/definition/Definition#;
28 use tl_iteratorrust-analyzer cargo tdlib-rs-parser 1.4.0 tl_iterator/::TlIteratorrust-analyzer cargo tdlib-rs-parser 1.4.0 tl_iterator/TlIterator#;
29
30 /// Parses a file full of [Type Language] definitions.
31 ///
32 /// # Examples
33 ///
34 /// ```no_run
35 /// use std::fs::File;
36 /// use std::io::{self, Read};
37 /// use tdlib_rs_parser::parse_tl_file;
38 ///
39 /// fn main() -> std::io::Result<()> {
40 /// let mut file = File::open("api.tl")?;
41 /// let mut contents = String::new();
42 /// file.read_to_string(&mut contents)?;
43 ///
44 /// for definition in parse_tl_file(contents) {
45 /// dbg!(definition);
46 /// }
47 ///
48 /// Ok(())
49 /// }
50 /// ```
51 ///
52 /// [Type Language]: https://core.telegram.org/mtproto/TL
53 pub fn parse_tl_filerust-analyzer cargo tdlib-rs-parser 1.4.0 parse_tl_file().(contents: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Definitionrust-analyzer cargo tdlib-rs-parser 1.4.0 tl/definition/Definition#, ParseErrorrust-analyzer cargo tdlib-rs-parser 1.4.0 errors/ParseError#>> {
54 TlIteratorrust-analyzer cargo tdlib-rs-parser 1.4.0 tl_iterator/TlIterator#::newrust-analyzer cargo tdlib-rs-parser 1.4.0 tl_iterator/impl#[TlIterator]new().(contents)
55 }