Debian Codegraph @

src/parser.rs

raw symbols SCIP
1 use libcrust-analyzer cargo libc 0.2.189 crate/;
2
3 use ffirust-analyzer cargo yaml 0.3.0 ffi/;
4 use error::{YamlError, YamlErrorContext, YamlMark};
5 use event::{YamlEvent, YamlEventSpec};
6 use document::{YamlDocument};
7 use codecsrust-analyzer cargo yaml 0.3.0 codecs/;
8
9 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/;
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/;
11 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#;
12 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/;
13 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#;
14
15 pub struct YamlEventStreamrust-analyzer cargo yaml 0.3.0 parser/YamlEventStream#<P> {
16 parserrust-analyzer cargo yaml 0.3.0 parser/YamlEventStream#parser.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<P>,
17 }
18
19 impl<P:YamlParserrust-analyzer cargo yaml 0.3.0 parser/YamlParser#> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for YamlEventStreamrust-analyzer cargo yaml 0.3.0 parser/YamlEventStream#<P> {
20 type Itemrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlEventStream<P>`][Iterator]Item# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<YamlEventrust-analyzer cargo yaml 0.3.0 event/YamlEvent#, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#>;
21
22 fn nextrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlEventStream<P>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<YamlEventrust-analyzer cargo yaml 0.3.0 event/YamlEvent#, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#>> {
23 unsafe {
24 match self.parserrust-analyzer cargo yaml 0.3.0 parser/YamlEventStream#parser..parse_eventrust-analyzer cargo yaml 0.3.0 parser/YamlParser#parse_event().() {
25 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(evt) => match evt.specrust-analyzer cargo yaml 0.3.0 event/YamlEvent#spec. {
26 YamlEventSpecrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#::YamlNoEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlNoEvent# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
27 _ => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(evt))
28 },
29 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(self.parserrust-analyzer cargo yaml 0.3.0 parser/YamlEventStream#parser..get_errorrust-analyzer cargo yaml 0.3.0 parser/YamlParser#get_error().()))
30 }
31 }
32 }
33 }
34
35 pub struct YamlDocumentStreamrust-analyzer cargo yaml 0.3.0 parser/YamlDocumentStream#<P> {
36 parserrust-analyzer cargo yaml 0.3.0 parser/YamlDocumentStream#parser.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<P>,
37 }
38
39 impl<P:YamlParserrust-analyzer cargo yaml 0.3.0 parser/YamlParser#> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for YamlDocumentStreamrust-analyzer cargo yaml 0.3.0 parser/YamlDocumentStream#<P> {
40 type Itemrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlDocumentStream<P>`][Iterator]Item# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<YamlDocumentrust-analyzer cargo yaml 0.3.0 document/YamlDocument#>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#>;
41
42 fn nextrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlDocumentStream<P>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<YamlDocumentrust-analyzer cargo yaml 0.3.0 document/YamlDocument#>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#>> {
43 unsafe {
44 match YamlDocumentrust-analyzer cargo yaml 0.3.0 document/YamlDocument#::parser_loadrust-analyzer cargo yaml 0.3.0 document/impl#[YamlDocument]parser_load().(&mut self.parserrust-analyzer cargo yaml 0.3.0 parser/YamlDocumentStream#parser..base_parser_refrust-analyzer cargo yaml 0.3.0 parser/YamlParser#base_parser_ref().().parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem.) {
45 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(doc) => if doc.is_emptyrust-analyzer cargo yaml 0.3.0 document/impl#[YamlDocument]is_empty().() {
46 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
47 } else {
48 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(doc))
49 },
50 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(self.parserrust-analyzer cargo yaml 0.3.0 parser/YamlDocumentStream#parser..get_errorrust-analyzer cargo yaml 0.3.0 parser/YamlParser#get_error().()))
51 }
52 }
53 }
54 }
55
56 pub struct InternalEventrust-analyzer cargo yaml 0.3.0 parser/InternalEvent# {
57 event_memrust-analyzer cargo yaml 0.3.0 parser/InternalEvent#event_mem.: ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_event_trust-analyzer cargo yaml 0.3.0 ffi/yaml_event_t#
58 }
59
60 impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for InternalEventrust-analyzer cargo yaml 0.3.0 parser/InternalEvent# {
61 fn droprust-analyzer cargo yaml 0.3.0 parser/impl#[InternalEvent][Drop]drop().(&mut self) {
62 unsafe {
63 self.event_memrust-analyzer cargo yaml 0.3.0 parser/InternalEvent#event_mem..deleterust-analyzer cargo yaml 0.3.0 ffi/impl#[yaml_event_t]delete().()
64 }
65 }
66 }
67
68 pub trait YamlParserrust-analyzer cargo yaml 0.3.0 parser/YamlParser#: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# {
69 unsafe fn base_parser_refrust-analyzer cargo yaml 0.3.0 parser/YamlParser#base_parser_ref().<'r>(&'r mut self) -> &'r mut YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#;
70 unsafe fn get_errorrust-analyzer cargo yaml 0.3.0 parser/YamlParser#get_error().(&mut self) -> YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#;
71
72 unsafe fn parse_eventrust-analyzer cargo yaml 0.3.0 parser/YamlParser#parse_event().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<YamlEventrust-analyzer cargo yaml 0.3.0 event/YamlEvent#> {
73 let mut event = InternalEventrust-analyzer cargo yaml 0.3.0 parser/InternalEvent# {
74 event_memrust-analyzer cargo yaml 0.3.0 parser/InternalEvent#event_mem.: memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::uninitializedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/uninitialized().()
75 };
76
77 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.base_parser_refrust-analyzer cargo yaml 0.3.0 parser/YamlParser#base_parser_ref().().parserust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]parse().(&mut event.event_memrust-analyzer cargo yaml 0.3.0 parser/InternalEvent#event_mem.) {
78 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
79 } else {
80 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(YamlEventrust-analyzer cargo yaml 0.3.0 event/YamlEvent#::loadrust-analyzer cargo yaml 0.3.0 event/impl#[YamlEvent]load().(&event.event_memrust-analyzer cargo yaml 0.3.0 parser/InternalEvent#event_mem.))
81 }
82 }
83
84 fn parserust-analyzer cargo yaml 0.3.0 parser/YamlParser#parse().(self: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Self>) -> YamlEventStreamrust-analyzer cargo yaml 0.3.0 parser/YamlEventStream#<Self> {
85 YamlEventStreamrust-analyzer cargo yaml 0.3.0 parser/YamlEventStream# {
86 parserrust-analyzer cargo yaml 0.3.0 parser/YamlEventStream#parser.: self,
87 }
88 }
89
90 fn loadrust-analyzer cargo yaml 0.3.0 parser/YamlParser#load().(self: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Self>) -> YamlDocumentStreamrust-analyzer cargo yaml 0.3.0 parser/YamlDocumentStream#<Self> {
91 YamlDocumentStreamrust-analyzer cargo yaml 0.3.0 parser/YamlDocumentStream# {
92 parserrust-analyzer cargo yaml 0.3.0 parser/YamlDocumentStream#parser.: self,
93 }
94 }
95 }
96
97 extern fn handle_reader_cbrust-analyzer cargo yaml 0.3.0 parser/handle_reader_cb().(data: *mut YamlIoParserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#, buffer: *mut u8, size: libcrust-analyzer cargo libc 0.2.189 crate/::size_trust-analyzer cargo libc 0.2.189 unix/size_t#, size_read: *mut libcrust-analyzer cargo libc 0.2.189 crate/::size_trust-analyzer cargo libc 0.2.189 unix/size_t#) -> 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# {
98 unsafe {
99 let buf = slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::from_raw_parts_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/raw/from_raw_parts_mut().(buffer, size as usize);
100 let parser = &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().data;
101 match parser.readerrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#reader..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(buf) {
102 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(size) => {
103 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().size_read = size as libcrust-analyzer cargo libc 0.2.189 crate/::size_trust-analyzer cargo libc 0.2.189 unix/size_t#;
104 return 1;
105 },
106 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => {
107 parser.io_errorrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#io_error. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(err);
108 return 0;
109 }
110 }
111 }
112 }
113
114 pub struct YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser# {
115 parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem.: ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_parser_trust-analyzer cargo yaml 0.3.0 ffi/yaml_parser_t#,
116 }
117
118 impl YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser# {
119 unsafe fn newrust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]new().() -> YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser# {
120 YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser# {
121 parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem.: memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::uninitializedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/uninitialized().()
122 }
123 }
124
125 unsafe fn initializerust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]initialize().(&mut self) -> bool {
126 ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_parser_initializerust-analyzer cargo yaml 0.3.0 yaml_parser_initialize().(&mut self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0
127 }
128
129 unsafe fn set_input_stringrust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]set_input_string().(&mut self, input: *const u8, size: usize) {
130 ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_parser_set_input_stringrust-analyzer cargo yaml 0.3.0 yaml_parser_set_input_string().(&mut self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem., input, size as libcrust-analyzer cargo libc 0.2.189 crate/::size_trust-analyzer cargo libc 0.2.189 unix/size_t#);
131 }
132
133 unsafe fn parserust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]parse().(&mut self, event: &mut ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_event_trust-analyzer cargo yaml 0.3.0 ffi/yaml_event_t#) -> bool {
134 ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_parser_parserust-analyzer cargo yaml 0.3.0 yaml_parser_parse().(&mut self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem., event) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0
135 }
136
137 unsafe fn build_errorrust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]build_error().(&self) -> YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError# {
138 let context = YamlErrorContextrust-analyzer cargo yaml 0.3.0 error/YamlErrorContext# {
139 byte_offsetrust-analyzer cargo yaml 0.3.0 error/YamlErrorContext#byte_offset.: self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem..problem_offsetrust-analyzer cargo yaml 0.3.0 ffi/yaml_parser_t#problem_offset. as usize,
140 problem_markrust-analyzer cargo yaml 0.3.0 error/YamlErrorContext#problem_mark.: YamlMarkrust-analyzer cargo yaml 0.3.0 error/YamlMark#::convrust-analyzer cargo yaml 0.3.0 error/impl#[YamlMark]conv().(&self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem..problem_markrust-analyzer cargo yaml 0.3.0 ffi/yaml_parser_t#problem_mark.),
141 contextrust-analyzer cargo yaml 0.3.0 error/YamlErrorContext#context.: codecsrust-analyzer cargo yaml 0.3.0 codecs/::decode_c_strrust-analyzer cargo yaml 0.3.0 codecs/decode_c_str().(self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem..contextrust-analyzer cargo yaml 0.3.0 ffi/yaml_parser_t#context. as *const ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_char_trust-analyzer cargo yaml 0.3.0 ffi/yaml_char_t#),
142 context_markrust-analyzer cargo yaml 0.3.0 error/YamlErrorContext#context_mark.: YamlMarkrust-analyzer cargo yaml 0.3.0 error/YamlMark#::convrust-analyzer cargo yaml 0.3.0 error/impl#[YamlMark]conv().(&self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem..context_markrust-analyzer cargo yaml 0.3.0 ffi/yaml_parser_t#context_mark.),
143 };
144
145 YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError# {
146 kindrust-analyzer cargo yaml 0.3.0 error/YamlError#kind.: self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem..errorrust-analyzer cargo yaml 0.3.0 ffi/yaml_parser_t#error.,
147 problemrust-analyzer cargo yaml 0.3.0 error/YamlError#problem.: codecsrust-analyzer cargo yaml 0.3.0 codecs/::decode_c_strrust-analyzer cargo yaml 0.3.0 codecs/decode_c_str().(self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem..problemrust-analyzer cargo yaml 0.3.0 ffi/yaml_parser_t#problem. as *const ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_char_trust-analyzer cargo yaml 0.3.0 ffi/yaml_char_t#),
148 io_errorrust-analyzer cargo yaml 0.3.0 error/YamlError#io_error.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
149 contextrust-analyzer cargo yaml 0.3.0 error/YamlError#context.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(context)
150 }
151 }
152 }
153
154 impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser# {
155 fn droprust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser][Drop]drop().(&mut self) {
156 unsafe {
157 ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_parser_deleterust-analyzer cargo yaml 0.3.0 yaml_parser_delete().(&mut self.parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem.);
158 }
159 }
160 }
161
162 pub struct YamlByteParserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#<'r> {
163 base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#base_parser.: YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#,
164 datarust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#data.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<&'r [u8]>
165 }
166
167 impl<'r> YamlParserrust-analyzer cargo yaml 0.3.0 parser/YamlParser# for YamlByteParserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#<'r> {
168 unsafe fn base_parser_refrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlByteParser<'r>`][YamlParser]base_parser_ref().<'a>(&'a mut self) -> &'a mut YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser# {
169 &mut self.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#base_parser.
170 }
171
172 unsafe fn get_errorrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlByteParser<'r>`][YamlParser]get_error().(&mut self) -> YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError# {
173 self.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#base_parser..build_errorrust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]build_error().()
174 }
175 }
176
177 impl<'r> YamlByteParserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#<'r> {
178 pub fn initrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlByteParser<'r>`]init().(bytes: &'r [u8], encoding: ffirust-analyzer cargo yaml 0.3.0 ffi/::YamlEncodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<YamlByteParserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#<'r>> {
179 unsafe {
180 let mut parser = Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(YamlByteParserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser# {
181 base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#base_parser.: YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#::newrust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]new().(),
182 datarust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#data.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#
183 });
184
185 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parser.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#base_parser..initializerust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]initialize().() {
186 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("failed to initialize yaml_parser_t");
187 }
188
189 ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_parser_set_encodingrust-analyzer cargo yaml 0.3.0 yaml_parser_set_encoding().(&mut parser.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#base_parser..parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem., encoding);
190 parser.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlByteParser#base_parser..set_input_stringrust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]set_input_string().(bytes.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().(), bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
191
192 parser
193 }
194 }
195 }
196
197 pub struct YamlIoParserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#<'r> {
198 base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#base_parser.: YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#,
199 readerrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#reader.: &'r mut (Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#+'r),
200 io_errorrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#io_error.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>,
201 }
202
203 impl<'r> YamlParserrust-analyzer cargo yaml 0.3.0 parser/YamlParser# for YamlIoParserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#<'r> {
204 unsafe fn base_parser_refrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlIoParser<'r>`][YamlParser]base_parser_ref().<'a>(&'a mut self) -> &'a mut YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser# {
205 &mut self.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#base_parser.
206 }
207
208 unsafe fn get_errorrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlIoParser<'r>`][YamlParser]get_error().(&mut self) -> YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError# {
209 let mut error = self.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#base_parser..build_errorrust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]build_error().();
210 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/swap().(&mut (error.io_errorrust-analyzer cargo yaml 0.3.0 error/YamlError#io_error.), &mut (self.io_errorrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#io_error.));
211 return error;
212 }
213 }
214
215 impl<'r> YamlIoParserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#<'r> {
216 pub fn initrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlIoParser<'r>`]init().<'a>(reader: &'a 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#) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<YamlIoParserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#<'a>> {
217 unsafe {
218 let mut parser = Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(YamlIoParserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser# {
219 base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#base_parser.: YamlBaseParserrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#::newrust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]new().(),
220 readerrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#reader.: reader,
221 io_errorrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#io_error.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
222 });
223
224 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parser.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#base_parser..initializerust-analyzer cargo yaml 0.3.0 parser/impl#[YamlBaseParser]initialize().() {
225 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("failed to initialize yaml_parser_t");
226 }
227
228 ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_parser_set_encodingrust-analyzer cargo yaml 0.3.0 yaml_parser_set_encoding().(&mut parser.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#base_parser..parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem., encoding);
229
230 ffirust-analyzer cargo yaml 0.3.0 ffi/::yaml_parser_set_inputrust-analyzer cargo yaml 0.3.0 yaml_parser_set_input().(&mut parser.base_parserrust-analyzer cargo yaml 0.3.0 parser/YamlIoParser#base_parser..parser_memrust-analyzer cargo yaml 0.3.0 parser/YamlBaseParser#parser_mem., handle_reader_cbrust-analyzer cargo yaml 0.3.0 parser/handle_reader_cb()., memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::transmuterust-analyzer cargo core https://github.com/rust-lang/rust/library/core intrinsics/transmute().(&mut *rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().parser));
231
232 parser
233 }
234 }
235 }
236
237 #[cfg(test)]
238 mod testrust-analyzer cargo yaml 0.3.0 parser/test/ {
239 use event::{YamlEventSpec, YamlSequenceParam, YamlScalarParam};
240 use event::YamlEventSpec::*;
241 use document::{YamlDocument, YamlNode};
242 use parserrust-analyzer cargo yaml 0.3.0 parser/;
243 use parserrust-analyzer cargo yaml 0.3.0 parser/::YamlParserrust-analyzer cargo yaml 0.3.0 parser/YamlParser#;
244 use error::YamlError;
245 use ffi::YamlErrorType;
246 use ffi::YamlEncoding::*;
247 use ffi::YamlScalarStyle::*;
248 use ffi::YamlSequenceStyle::*;
249 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#;
250
251 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
252 fn test_byte_parserrust-analyzer cargo yaml 0.3.0 parser/test/test_byte_parser().() {
253 let data = "[1, 2, 3]";
254 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().(data.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#);
255 let expected = 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!![
256 YamlStreamStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlStreamStartEvent#(YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#),
257 YamlDocumentStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlDocumentStartEvent#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], true),
258 YamlSequenceStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlSequenceStartEvent#(YamlSequenceParamrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, implicitrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#implicit.: true, stylerust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#style.: YamlFlowSequenceStylerust-analyzer cargo yaml 0.3.0 ffi/YamlSequenceStyle#YamlFlowSequenceStyle#}),
259 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: true, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: false, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlPlainScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlPlainScalarStyle#}),
260 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: true, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: false, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlPlainScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlPlainScalarStyle#}),
261 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "3".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: true, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: false, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlPlainScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlPlainScalarStyle#}),
262 YamlSequenceEndEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlSequenceEndEvent#,
263 YamlDocumentEndEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlDocumentEndEvent#(true),
264 YamlStreamEndEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlStreamEndEvent#
265 ]);
266
267 let stream: 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#<YamlEventSpecrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#> = parser.parserust-analyzer cargo yaml 0.3.0 parser/YamlParser#parse().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|res| res.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|evt| evt.specrust-analyzer cargo yaml 0.3.0 event/YamlEvent#spec.)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
268
269 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, stream);
270 }
271
272 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
273 fn test_io_parserrust-analyzer cargo yaml 0.3.0 parser/test/test_io_parser().() {
274 let data = "[1, 2, 3]";
275 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().());
276 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().(&mut reader, YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#);
277 let expected = 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!![
278 YamlStreamStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlStreamStartEvent#(YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#),
279 YamlDocumentStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlDocumentStartEvent#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], true),
280 YamlSequenceStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlSequenceStartEvent#(YamlSequenceParamrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, implicitrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#implicit.: true, stylerust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#style.: YamlFlowSequenceStylerust-analyzer cargo yaml 0.3.0 ffi/YamlSequenceStyle#YamlFlowSequenceStyle#}),
281 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: true, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: false, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlPlainScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlPlainScalarStyle#}),
282 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: true, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: false, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlPlainScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlPlainScalarStyle#}),
283 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "3".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: true, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: false, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlPlainScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlPlainScalarStyle#}),
284 YamlSequenceEndEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlSequenceEndEvent#,
285 YamlDocumentEndEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlDocumentEndEvent#(true),
286 YamlStreamEndEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlStreamEndEvent#
287 ]);
288
289 let stream: 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#<YamlEventSpecrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#> = parser.parserust-analyzer cargo yaml 0.3.0 parser/YamlParser#parse().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|res| res.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|evt| evt.specrust-analyzer cargo yaml 0.3.0 event/YamlEvent#spec.)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
290
291 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, stream);
292 }
293
294 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
295 fn test_byte_parser_mappingrust-analyzer cargo yaml 0.3.0 parser/test/test_byte_parser_mapping().() {
296 let data = "{\"a\": 1, \"b\":2}";
297 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().(data.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#);
298 let expected = 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!![
299 YamlStreamStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlStreamStartEvent#(YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#),
300 YamlDocumentStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlDocumentStartEvent#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], true),
301 YamlMappingStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlMappingStartEvent#(YamlSequenceParamrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, implicitrust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#implicit.: true, stylerust-analyzer cargo yaml 0.3.0 event/YamlSequenceParam#style.: YamlFlowSequenceStylerust-analyzer cargo yaml 0.3.0 ffi/YamlSequenceStyle#YamlFlowSequenceStyle#}),
302 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "a".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: false, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: true, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlDoubleQuotedScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlDoubleQuotedScalarStyle#}),
303 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: true, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: false, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlPlainScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlPlainScalarStyle#}),
304 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "b".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: false, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: true, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlDoubleQuotedScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlDoubleQuotedScalarStyle#}),
305 YamlScalarEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlScalarEvent#(YamlScalarParamrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#{anchorrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#anchor.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, tagrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#tag.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, valuerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#value.: "2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), plain_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#plain_implicit.: true, quoted_implicitrust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#quoted_implicit.: false, stylerust-analyzer cargo yaml 0.3.0 event/YamlScalarParam#style.: YamlPlainScalarStylerust-analyzer cargo yaml 0.3.0 ffi/YamlScalarStyle#YamlPlainScalarStyle#}),
306 YamlMappingEndEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlMappingEndEvent#,
307 YamlDocumentEndEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlDocumentEndEvent#(true),
308 YamlStreamEndEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlStreamEndEvent#
309 ]);
310
311 let stream: 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#<YamlEventSpecrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#> = parser.parserust-analyzer cargo yaml 0.3.0 parser/YamlParser#parse().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|res| res.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|evt| evt.specrust-analyzer cargo yaml 0.3.0 event/YamlEvent#spec.)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
312
313 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, stream);
314 }
315
316 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
317 fn test_parser_errorrust-analyzer cargo yaml 0.3.0 parser/test/test_parser_error().() {
318 let data = "\"ab";
319 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().(data.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#);
320 let mut stream = parser.parserust-analyzer cargo yaml 0.3.0 parser/YamlParser#parse().();
321
322 let stream_start = stream.nextrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlEventStream<P>`][Iterator]next().();
323 match stream_start {
324 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(evt)) => assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(YamlStreamStartEventrust-analyzer cargo yaml 0.3.0 event/YamlEventSpec#YamlStreamStartEvent#(YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#), evt.specrust-analyzer cargo yaml 0.3.0 event/YamlEvent#spec.),
325 res => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unexpected result: {:?}", res)
326 }
327
328 let stream_err = stream.nextrust-analyzer cargo yaml 0.3.0 parser/impl#[`YamlEventStream<P>`][Iterator]next().();
329 match stream_err {
330 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err)) => assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(YamlErrorTyperust-analyzer cargo yaml 0.3.0 ffi/YamlErrorType#::YAML_SCANNER_ERRORrust-analyzer cargo yaml 0.3.0 ffi/YamlErrorType#YAML_SCANNER_ERROR#, err.kindrust-analyzer cargo yaml 0.3.0 error/YamlError#kind.),
331 evt => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unexpected result: {:?}", evt),
332 }
333 }
334
335 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
336 fn test_documentrust-analyzer cargo yaml 0.3.0 parser/test/test_document().() {
337 let data = "[1, 2, 3]";
338 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().(data.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#);
339 let docs_res: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#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<YamlDocumentrust-analyzer cargo yaml 0.3.0 document/YamlDocument#>>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#> = parser.loadrust-analyzer cargo yaml 0.3.0 parser/YamlParser#load().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
340
341 match docs_res {
342 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unexpected result: {:?}", e),
343 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(docs) => match docs[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|doc| doc.rootrust-analyzer cargo yaml 0.3.0 document/impl#[YamlDocument]root().()) {
344 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(YamlNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#::YamlSequenceNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#YamlSequenceNode#(seq)) => {
345 let values:Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = seq.valuesrust-analyzer cargo yaml 0.3.0 document/impl#[`YamlSequenceData<'r>`]values().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|node| {
346 match node {
347 YamlNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#::YamlScalarNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#YamlScalarNode#(scalar) => scalar.get_valuerust-analyzer cargo yaml 0.3.0 document/impl#[`YamlScalarData<'r>`]get_value().(),
348 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unexpected scalar")
349 }
350 }).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
351 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "3".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()], values)
352 },
353 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unexpected result")
354 }
355 }
356 }
357
358 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
359 fn test_mapping_documentrust-analyzer cargo yaml 0.3.0 parser/test/test_mapping_document().() {
360 let data = "{\"a\": 1, \"b\": 2}";
361 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().(data.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), YamlUtf8Encodingrust-analyzer cargo yaml 0.3.0 ffi/YamlEncoding#YamlUtf8Encoding#);
362 let docs_res: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#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<YamlDocumentrust-analyzer cargo yaml 0.3.0 document/YamlDocument#>>, YamlErrorrust-analyzer cargo yaml 0.3.0 error/YamlError#> = parser.loadrust-analyzer cargo yaml 0.3.0 parser/YamlParser#load().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
363
364 match docs_res {
365 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unexpected result: {:?}", e),
366 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(docs) => match docs[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|doc| doc.rootrust-analyzer cargo yaml 0.3.0 document/impl#[YamlDocument]root().()) {
367 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(YamlNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#::YamlMappingNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#YamlMappingNode#(seq)) => {
368 let values:Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)> = seq.pairsrust-analyzer cargo yaml 0.3.0 document/impl#[`YamlMappingData<'r>`]pairs().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(key, value)| {
369 (
370 match key {
371 YamlNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#::YamlScalarNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#YamlScalarNode#(scalar) => scalar.get_valuerust-analyzer cargo yaml 0.3.0 document/impl#[`YamlScalarData<'r>`]get_value().(),
372 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unexpected scalar")
373 },
374 match value {
375 YamlNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#::YamlScalarNoderust-analyzer cargo yaml 0.3.0 document/YamlNode#YamlScalarNode#(scalar) => scalar.get_valuerust-analyzer cargo yaml 0.3.0 document/impl#[`YamlScalarData<'r>`]get_value().(),
376 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unexpected scalar")
377 }
378 )
379 }).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
380 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("a".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), ("b".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())], values)
381 },
382 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("unexpected result")
383 }
384 }
385 }
386 }