Struct webparse::Helper

source ·
pub struct Helper;

Implementations§

source§

impl Helper

source

pub fn is_token(b: u8) -> bool

Determines if byte is a token char.

token          = 1*tchar

tchar          = "!" / "#" / "$" / "%" / "&" / "'" / "*"
               / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
               / DIGIT / ALPHA
               ; any VCHAR, except delimiters
source

pub fn is_status_token(b: u8) -> bool

source

pub fn is_alpha(b: u8) -> bool

source

pub const DIGIT_0: u8 = 48u8

source

pub fn is_digit(b: u8) -> bool

source

pub fn is_hex(b: u8) -> bool

source

pub fn to_hex(b: u8) -> u8

Examples found in repository?
examples/demo.rs (line 66)
62
63
64
65
66
67
68
69
70
71
fn hex_debug_print(val: &[u8]) {
    for v in val {
        print!(
            "{}{}  ",
            String::from_utf8_lossy(&vec![Helper::to_hex(v / 16)]),
            String::from_utf8_lossy(&vec![Helper::to_hex(v % 16)])
        );
    }
    println!();
}
source

pub fn convert_hex(b: u8) -> Option<u8>

source

pub fn is_uri_token(b: u8) -> bool

source

pub fn skip_new_line<B: Buf>(buffer: &mut B) -> WebResult<()>

source

pub fn parse_chunk_data<'a, B: Buf>( buffer: &'a mut B ) -> WebResult<(usize, usize)>

source

pub fn encode_chunk_data<B: Buf + BufMut>( buffer: &mut B, data: &[u8] ) -> Result<usize>

source

pub fn hex_to_vec(s: &str) -> Vec<u8>

Examples found in repository?
examples/http2.rs (line 7)
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
fn parse_header() {
    let mut decoder = Decoder::new();
    // C.4.1
    let buf = Helper::hex_to_vec("8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 ff");
    let buf_len = buf.len();
    let mut header = Headers::empty();
    let size = header.parse(BinaryMut::from(buf), &mut decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE).unwrap();
    assert!(size == buf_len);
    assert!(header.method() == &Some(Method::Get));
    assert!(header.path() == &Some("/".to_string()));
    assert!(header.scheme() == &Some(Scheme::Http));
    assert!(header.authority() == &Some("www.example.com".to_string()));

    // C.4.2
    let buf = Helper::hex_to_vec("8286 84be 5886 a8eb 1064 9cbf");
    let buf_len = buf.len();
    let mut header = Headers::empty();
    let size = header.parse(BinaryMut::from(buf), &mut decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE).unwrap();
    assert!(size == buf_len);
    assert!(header.method() == &Some(Method::Get));
    assert!(header.path() == &Some("/".to_string()));
    assert!(header.scheme() == &Some(Scheme::Http));
    assert!(header.authority() == &Some("www.example.com".to_string()));
    assert!(header.fields()["cache-control"] == "no-cache");

    // C.4.3
    let buf = Helper::hex_to_vec("8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 a849 e95b b8e8 b4bf ");
    let buf_len = buf.len();
    let mut header = Headers::empty();
    let size = header.parse(BinaryMut::from(buf), &mut decoder, DEFAULT_SETTINGS_HEADER_TABLE_SIZE).unwrap();
    assert!(size == buf_len);
    assert!(header.method() == &Some(Method::Get));
    assert!(header.path() == &Some("/index.html".to_string()));
    assert!(header.scheme() == &Some(Scheme::Https));
    assert!(header.authority() == &Some("www.example.com".to_string()));
    assert!(header.fields()["custom-key"] == "custom-value");
}
source

pub fn eq_bytes_ignore_ascii_case(a: &[u8], b: &[u8]) -> bool

source

pub fn eq_bytes(a: &[u8], b: &[u8]) -> bool

source

pub fn contains_bytes(a: &[u8], b: &[u8]) -> bool

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.