@@ -142,35 +142,35 @@ pub use ns_reader::NsReader;
142
142
/// subgraph _
143
143
/// direction LR
144
144
///
145
- /// Init -- "(no event)"\nStartText --> Opened
146
- /// Opened -- Decl, DocType, PI\nComment, CData\nStart, Empty, End --> Closed
147
- /// Closed -- "#lt;false#gt;\n(no event)"\nText --> Opened
145
+ /// Init -- "(no event)"\nStartText --> OpenedTag
146
+ /// OpenedTag -- Decl, DocType, PI\nComment, CData\nStart, Empty, End --> ClosedTag
147
+ /// ClosedTag -- "#lt;false#gt;\n(no event)"\nText --> OpenedTag
148
148
/// end
149
- /// Closed -- "#lt;true#gt;"\nStart --> Empty
150
- /// Empty -- End --> Closed
149
+ /// ClosedTag -- "#lt;true#gt;"\nStart --> Empty
150
+ /// Empty -- End --> ClosedTag
151
151
/// _ -. Eof .-> Exit
152
152
/// ```
153
153
#[ derive( Clone ) ]
154
- enum TagState {
154
+ enum ParseState {
155
155
/// Initial state in which reader stay after creation. Transition from that
156
156
/// state could produce a `StartText`, `Decl`, `Comment` or `Start` event.
157
- /// The next state is always `Opened `. The reader will never return to this
158
- /// state. The event emitted during transition to `Opened ` is a `StartEvent`
157
+ /// The next state is always `OpenedTag `. The reader will never return to this
158
+ /// state. The event emitted during transition to `OpenedTag ` is a `StartEvent`
159
159
/// if the first symbol not `<`, otherwise no event are emitted.
160
160
Init ,
161
161
/// State after seeing the `<` symbol. Depending on the next symbol all other
162
162
/// events (except `StartText`) could be generated.
163
163
///
164
- /// After generating ane event the reader moves to the `Closed ` state.
165
- Opened ,
164
+ /// After generating ane event the reader moves to the `ClosedTag ` state.
165
+ OpenedTag ,
166
166
/// State in which reader searches the `<` symbol of a markup. All bytes before
167
167
/// that symbol will be returned in the [`Event::Text`] event. After that
168
- /// the reader moves to the `Opened ` state.
169
- Closed ,
168
+ /// the reader moves to the `OpenedTag ` state.
169
+ ClosedTag ,
170
170
/// This state is used only if option `expand_empty_elements` is set to `true`.
171
- /// Reader enters to this state when it is in a `Closed ` state and emits an
171
+ /// Reader enters to this state when it is in a `ClosedTag ` state and emits an
172
172
/// [`Event::Start`] event. The next event emitted will be an [`Event::End`],
173
- /// after which reader returned to the `Closed ` state.
173
+ /// after which reader returned to the `ClosedTag ` state.
174
174
Empty ,
175
175
/// Reader enters this state when `Eof` event generated or an error occurred.
176
176
/// This is the last state, the reader stay in it forever.
@@ -374,9 +374,9 @@ impl<R> Reader<R> {
374
374
///
375
375
/// Useful when debugging errors.
376
376
pub fn buffer_position ( & self ) -> usize {
377
- // when internal state is Opened , we have actually read until '<',
377
+ // when internal state is OpenedTag , we have actually read until '<',
378
378
// which we don't want to show
379
- if let TagState :: Opened = self . parser . tag_state {
379
+ if let ParseState :: OpenedTag = self . parser . state {
380
380
self . parser . offset - 1
381
381
} else {
382
382
self . parser . offset
@@ -405,28 +405,28 @@ impl<R> Reader<R> {
405
405
where
406
406
R : XmlSource < ' i , B > ,
407
407
{
408
- let event = match self . parser . tag_state {
409
- TagState :: Init => self . read_until_open ( buf, true ) ,
410
- TagState :: Closed => self . read_until_open ( buf, false ) ,
411
- TagState :: Opened => self . read_until_close ( buf) ,
412
- TagState :: Empty => self . parser . close_expanded_empty ( ) ,
413
- TagState :: Exit => return Ok ( Event :: Eof ) ,
408
+ let event = match self . parser . state {
409
+ ParseState :: Init => self . read_until_open ( buf, true ) ,
410
+ ParseState :: ClosedTag => self . read_until_open ( buf, false ) ,
411
+ ParseState :: OpenedTag => self . read_until_close ( buf) ,
412
+ ParseState :: Empty => self . parser . close_expanded_empty ( ) ,
413
+ ParseState :: Exit => return Ok ( Event :: Eof ) ,
414
414
} ;
415
415
match event {
416
- Err ( _) | Ok ( Event :: Eof ) => self . parser . tag_state = TagState :: Exit ,
416
+ Err ( _) | Ok ( Event :: Eof ) => self . parser . state = ParseState :: Exit ,
417
417
_ => { }
418
418
}
419
419
event
420
420
}
421
421
422
- /// Read until '<' is found and moves reader to an `Opened ` state.
422
+ /// Read until '<' is found and moves reader to an `OpenedTag ` state.
423
423
///
424
424
/// Return a `StartText` event if `first` is `true` and a `Text` event otherwise
425
425
fn read_until_open < ' i , B > ( & mut self , buf : B , first : bool ) -> Result < Event < ' i > >
426
426
where
427
427
R : XmlSource < ' i , B > ,
428
428
{
429
- self . parser . tag_state = TagState :: Opened ;
429
+ self . parser . state = ParseState :: OpenedTag ;
430
430
431
431
if self . parser . trim_text_start {
432
432
self . reader . skip_whitespace ( & mut self . parser . offset ) ?;
@@ -453,7 +453,7 @@ impl<R> Reader<R> {
453
453
where
454
454
R : XmlSource < ' i , B > ,
455
455
{
456
- self . parser . tag_state = TagState :: Closed ;
456
+ self . parser . state = ParseState :: ClosedTag ;
457
457
458
458
match self . reader . peek_one ( ) {
459
459
// `<!` - comment, CDATA or DOCTYPE declaration
0 commit comments