1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use lut::{Table};
use lookup_tables::{
MediaTypeChars,
QTextWs,
HttpToken
};
use qs::error::CoreError;
use qs::spec::{
PartialCodePoint,
ParsingImpl,
State,
WithoutQuotingValidator,
};
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
pub struct HttpObsParsingImpl;
impl ParsingImpl for HttpObsParsingImpl {
fn can_be_quoted(bch: PartialCodePoint) -> bool {
let idx = bch.as_u8() as usize;
idx > 0x7f || MediaTypeChars::check_at(idx, QTextWs)
}
fn handle_normal_state(bch: PartialCodePoint) -> Result<(State<Self>, bool), CoreError> {
let idx = bch.as_u8() as usize;
if idx > 0x7f || MediaTypeChars::check_at(idx, QTextWs) {
Ok((State::Normal, true))
} else {
Err(CoreError::InvalidChar)
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
pub struct HttpTokenValidator;
impl HttpTokenValidator {
pub fn new() -> Self {
Default::default()
}
}
impl WithoutQuotingValidator for HttpTokenValidator {
fn next(&mut self, pcp: PartialCodePoint) -> bool {
MediaTypeChars::check_at(pcp.as_u8() as usize, HttpToken)
}
fn end(&self) -> bool {
true
}
}