Debian Codegraph @

src/lib.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #![crate_name = "yaml"]
2 #![crate_type = "lib"]
3
4 extern crate libcrust-analyzer cargo yaml 0.3.0 libc/;
5
6 extern crate regexrust-analyzer cargo yaml 0.3.0 regex/;
7
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/;
9 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#;
10 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#;
11
12 use parserrust-analyzer cargo yaml 0.3.0 parser/::YamlParserrust-analyzer cargo yaml 0.3.0 parser/YamlParser#;
13 use constructorrust-analyzer cargo yaml 0.3.0 constructor/::{YamlStandardDatarust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#, YamlStandardConstructorrust-analyzer cargo yaml 0.3.0 constructor/YamlStandardConstructor#, YamlConstructorrust-analyzer cargo yaml 0.3.0 constructor/YamlConstructor#};
14 use errorrust-analyzer cargo yaml 0.3.0 error/::YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#;
15
16 pub mod ffirust-analyzer cargo yaml 0.3.0 ffi/;
17 pub mod errorrust-analyzer cargo yaml 0.3.0 error/;
18 pub mod eventrust-analyzer cargo yaml 0.3.0 event/;
19 pub mod parserrust-analyzer cargo yaml 0.3.0 parser/;
20 pub mod emitterrust-analyzer cargo yaml 0.3.0 emitter/;
21 pub mod documentrust-analyzer cargo yaml 0.3.0 document/;
22 pub mod codecsrust-analyzer cargo yaml 0.3.0 codecs/;
23 pub mod constructorrust-analyzer cargo yaml 0.3.0 constructor/;
24
25 mod type_sizerust-analyzer cargo yaml 0.3.0 type_size/;
26
27 pub fn version_stringrust-analyzer cargo yaml 0.3.0 version_string().() -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
28 unsafe {
29 strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#::from_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]from_ptr().(ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_get_version_stringrust-analyzer cargo yaml 0.3.0 yaml_get_version_string().()).to_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]to_bytes().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
30 }
31 }
32
33 pub fn versionrust-analyzer cargo yaml 0.3.0 version().() -> (isize, isize, isize) {
34 let mut c_major: libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int# = 0;
35 let mut c_minor: libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int# = 0;
36 let mut c_patch: libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int# = 0;
37
38 unsafe {
39 ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_get_versionrust-analyzer cargo yaml 0.3.0 yaml_get_version().(
40 &mut c_major as *mut libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int#,
41 &mut c_minor as *mut libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int#,
42 &mut c_patch as *mut libcrust-analyzer cargo libc 0.2.189 crate/::c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int#
43 );
44 }
45
46 (c_major as isize, c_minor as isize, c_patch as isize)
47 }
48
49 pub fn parse_bytes_utf8rust-analyzer cargo yaml 0.3.0 parse_bytes_utf8().(bytes: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<YamlStandardDatarust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#> {
50 parse_bytesrust-analyzer cargo yaml 0.3.0 parse_bytes().(bytes, ffirust-analyzer cargo yaml 0.3.0 ffi/::YamlEncodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#::YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#)
51 }
52
53 pub fn parse_bytesrust-analyzer cargo yaml 0.3.0 parse_bytes().(bytes: &[u8], encoding: ffirust-analyzer cargo yaml 0.3.0 ffi/::YamlEncodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<YamlStandardDatarust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#> {
54 let parser = parserrust-analyzer cargo yaml 0.3.0 parser/::YamlByteParserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#::initrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlByteParser<'r>`]init().(bytes, encoding);
55 let ctor = YamlStandardConstructorrust-analyzer cargo yaml 0.3.0 constructor/YamlStandardConstructor#::newrust-analyzer cargo yaml 0.3.0 constructor/impl#[YamlStandardConstructor]new().();
56
57 parser.loadrust-analyzer cargo yaml 0.3.0 parser/YamlParser#load().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|doc_res|
58 doc_res.and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(|doc| ctor.constructrust-analyzer cargo yaml 0.3.0 constructor/YamlConstructor#construct().(doc.rootrust-analyzer cargo yaml 0.3.0 document/impl#[YamlDocument]root().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()))
59 ).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
60 }
61
62 pub fn parse_io_utf8rust-analyzer cargo yaml 0.3.0 parse_io_utf8().(reader: &mut Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<YamlStandardDatarust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#> {
63 parse_iorust-analyzer cargo yaml 0.3.0 parse_io().(reader, ffirust-analyzer cargo yaml 0.3.0 ffi/::YamlEncodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#::YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#)
64 }
65
66 pub fn parse_iorust-analyzer cargo yaml 0.3.0 parse_io().(reader: &mut Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, encoding: ffirust-analyzer cargo yaml 0.3.0 ffi/::YamlEncodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<YamlStandardDatarust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#> {
67 let parser = parserrust-analyzer cargo yaml 0.3.0 parser/::YamlIoParserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#::initrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlIoParser<'r>`]init().(reader, encoding);
68 let ctor = YamlStandardConstructorrust-analyzer cargo yaml 0.3.0 constructor/YamlStandardConstructor#::newrust-analyzer cargo yaml 0.3.0 constructor/impl#[YamlStandardConstructor]new().();
69
70 parser.loadrust-analyzer cargo yaml 0.3.0 parser/YamlParser#load().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|doc_res|
71 doc_res.and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(|doc| ctor.constructrust-analyzer cargo yaml 0.3.0 constructor/YamlConstructor#construct().(doc.rootrust-analyzer cargo yaml 0.3.0 document/impl#[YamlDocument]root().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()))
72 ).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
73 }
74
75 #[cfg(test)]
76 mod testrust-analyzer cargo yaml 0.3.0 test/ {
77 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/;
78 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#;
79 use constructor::YamlStandardData::*;
80
81 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
82 fn test_version_stringrust-analyzer cargo yaml 0.3.0 test/test_version_string().() {
83 let vsn = superrust-analyzer cargo yaml 0.3.0 crate/::version_stringrust-analyzer cargo yaml 0.3.0 version_string().();
•84 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!("0.1.4".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() <= vsn && vsn <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). "0.3".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
85 }
86
87 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
88 fn test_versionrust-analyzer cargo yaml 0.3.0 test/test_version().() {
89 let vsn = superrust-analyzer cargo yaml 0.3.0 crate/::versionrust-analyzer cargo yaml 0.3.0 version().();
•90 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!((0, 1, 4) <= vsn && vsn <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core tuple/impl#[`(V, U, T)`][`PartialOrd<Self>`]lt(). (0, 3, 0))
91 }
92
93 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
94 fn test_event_sizerust-analyzer cargo yaml 0.3.0 test/test_event_size().() {
95 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo yaml 0.3.0 crate/::type_sizerust-analyzer cargo yaml 0.3.0 type_size/::YAML_EVENT_T_SIZErust-analyzer cargo yaml 0.3.0 type_size/YAML_EVENT_T_SIZE., memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<superrust-analyzer cargo yaml 0.3.0 crate/::ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_event_trust-analyzer cargo yaml 0.3.0 ffi/yaml_event_t#>())
96 }
97
98 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
99 fn test_parser_sizerust-analyzer cargo yaml 0.3.0 test/test_parser_size().() {
100 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo yaml 0.3.0 crate/::type_sizerust-analyzer cargo yaml 0.3.0 type_size/::YAML_PARSER_T_SIZErust-analyzer cargo yaml 0.3.0 type_size/YAML_PARSER_T_SIZE., memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<superrust-analyzer cargo yaml 0.3.0 crate/::ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_parser_trust-analyzer cargo yaml 0.3.0 ffi/yaml_parser_t#>())
101 }
102
103 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
104 fn test_emitter_sizerust-analyzer cargo yaml 0.3.0 test/test_emitter_size().() {
105 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo yaml 0.3.0 crate/::type_sizerust-analyzer cargo yaml 0.3.0 type_size/::YAML_EMITTER_T_SIZErust-analyzer cargo yaml 0.3.0 type_size/YAML_EMITTER_T_SIZE., memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<superrust-analyzer cargo yaml 0.3.0 crate/::ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_emitter_trust-analyzer cargo yaml 0.3.0 ffi/yaml_emitter_t#>())
106 }
107
108 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
109 fn test_document_sizerust-analyzer cargo yaml 0.3.0 test/test_document_size().() {
110 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo yaml 0.3.0 crate/::type_sizerust-analyzer cargo yaml 0.3.0 type_size/::YAML_DOCUMENT_T_SIZErust-analyzer cargo yaml 0.3.0 type_size/YAML_DOCUMENT_T_SIZE., memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<superrust-analyzer cargo yaml 0.3.0 crate/::ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_document_trust-analyzer cargo yaml 0.3.0 ffi/yaml_document_t#>())
111 }
112
113 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
114 fn test_node_sizerust-analyzer cargo yaml 0.3.0 test/test_node_size().() {
115 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(superrust-analyzer cargo yaml 0.3.0 crate/::type_sizerust-analyzer cargo yaml 0.3.0 type_size/::YAML_NODE_T_SIZErust-analyzer cargo yaml 0.3.0 type_size/YAML_NODE_T_SIZE., memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<superrust-analyzer cargo yaml 0.3.0 crate/::ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_node_trust-analyzer cargo yaml 0.3.0 ffi/yaml_node_t#>())
116 }
117
118 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
119 fn test_parse_bytesrust-analyzer cargo yaml 0.3.0 test/test_parse_bytes().() {
120 let data = "[1, 2, 3]";
121 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![YamlSequencerust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#YamlSequence#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![YamlIntegerrust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#YamlInteger#(1), YamlIntegerrust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#YamlInteger#(2), YamlIntegerrust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#YamlInteger#(3)])]), superrust-analyzer cargo yaml 0.3.0 crate/::parse_bytes_utf8rust-analyzer cargo yaml 0.3.0 parse_bytes_utf8().(data.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()))
122 }
123
124 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
125 fn test_parse_iorust-analyzer cargo yaml 0.3.0 test/test_parse_io().() {
126 let data = "[1, 2, 3]";
127 let mut reader = BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]new().(data.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().());
128 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![YamlSequencerust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#YamlSequence#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![YamlIntegerrust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#YamlInteger#(1), YamlIntegerrust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#YamlInteger#(2), YamlIntegerrust-analyzer cargo yaml 0.3.0 constructor/YamlStandardData#YamlInteger#(3)])]), superrust-analyzer cargo yaml 0.3.0 crate/::parse_io_utf8rust-analyzer cargo yaml 0.3.0 parse_io_utf8().(&mut reader))
129 }
130 }