From 4892172b629590ac4362f7506c14e993fd1ddd2b Mon Sep 17 00:00:00 2001
From: Martin Fischer <martin@push-f.com>
Date: Tue, 30 Nov 2021 15:34:57 +0100
Subject: prepare for introduction of public State enum

---
 src/lib.rs             |  2 +-
 src/tokenizer.rs       | 20 +++++++++++---------
 tests/test_html5lib.rs |  6 ++++--
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index f3e0431..2125776 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -13,7 +13,7 @@ mod tokenizer;
 mod utils;
 
 #[cfg(feature = "integration-tests")]
-pub use utils::State;
+pub use utils::State as InternalState;
 
 pub use emitter::{DefaultEmitter, Doctype, Emitter, EndTag, StartTag, Token};
 pub use error::Error;
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index ec3ae44..b09e030 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -1,5 +1,7 @@
 use crate::machine;
-use crate::utils::{control_pat, noncharacter_pat, surrogate_pat, ControlToken, State};
+use crate::utils::{
+    control_pat, noncharacter_pat, surrogate_pat, ControlToken, State as InternalState,
+};
 use crate::{DefaultEmitter, Emitter, Error, Never, Readable, Reader};
 
 // this is a stack that can hold 0 to 2 Ts
@@ -31,13 +33,13 @@ impl<T: Copy> Stack2<T> {
 /// A HTML tokenizer. See crate-level docs for basic usage.
 pub struct Tokenizer<R: Reader, E: Emitter = DefaultEmitter> {
     eof: bool,
-    pub(crate) state: State,
+    pub(crate) state: InternalState,
     pub(crate) emitter: E,
     pub(crate) temporary_buffer: String,
     reader: R,
     to_reconsume: Stack2<Option<char>>,
     pub(crate) character_reference_code: u32,
-    pub(crate) return_state: Option<State>,
+    pub(crate) return_state: Option<InternalState>,
 }
 
 impl<R: Reader> Tokenizer<R> {
@@ -61,7 +63,7 @@ impl<R: Reader, E: Emitter> Tokenizer<R, E> {
     pub fn new_with_emitter<'a, S: Readable<'a, Reader = R>>(input: S, emitter: E) -> Self {
         Tokenizer {
             eof: false,
-            state: State::Data,
+            state: InternalState::Data,
             emitter,
             temporary_buffer: String::new(),
             to_reconsume: Stack2::default(),
@@ -75,7 +77,7 @@ impl<R: Reader, E: Emitter> Tokenizer<R, E> {
     ///
     /// Only available with the `integration-tests` feature which is not public API.
     #[cfg(feature = "integration-tests")]
-    pub fn set_state(&mut self, state: State) {
+    pub fn set_internal_state(&mut self, state: InternalState) {
         self.state = state;
     }
 
@@ -84,7 +86,7 @@ impl<R: Reader, E: Emitter> Tokenizer<R, E> {
     ///
     /// This tokenizer never gets into that state naturally.
     pub fn set_plaintext_state(&mut self) {
-        self.state = State::PlainText;
+        self.state = InternalState::PlainText;
     }
 
     /// Test-internal function to override internal state.
@@ -176,9 +178,9 @@ impl<R: Reader, E: Emitter> Tokenizer<R, E> {
         matches!(
             self.return_state,
             Some(
-                State::AttributeValueDoubleQuoted
-                    | State::AttributeValueSingleQuoted
-                    | State::AttributeValueUnquoted
+                InternalState::AttributeValueDoubleQuoted
+                    | InternalState::AttributeValueSingleQuoted
+                    | InternalState::AttributeValueUnquoted
             )
         )
     }
diff --git a/tests/test_html5lib.rs b/tests/test_html5lib.rs
index 652a72d..cb11a00 100644
--- a/tests/test_html5lib.rs
+++ b/tests/test_html5lib.rs
@@ -1,4 +1,6 @@
-use html5gum::{Doctype, EndTag, Error, Reader, StartTag, State, Token, Tokenizer};
+use html5gum::{
+    Doctype, EndTag, Error, InternalState as State, Reader, StartTag, Token, Tokenizer,
+};
 use pretty_assertions::assert_eq;
 use serde::{de::Error as _, Deserialize};
 use std::{collections::BTreeMap, fs::File, io::BufReader, path::Path};
@@ -258,7 +260,7 @@ fn run_test_inner<R: Reader>(
         fname, test_i, state, tokenizer_info,
     );
     println!("description: {}", test.description);
-    tokenizer.set_state(state);
+    tokenizer.set_internal_state(state);
     tokenizer.set_last_start_tag(test.last_start_tag.as_ref().map(String::as_str));
 
     let mut actual_tokens = Vec::new();
-- 
cgit v1.2.3