pub struct Helper;Implementations§
Source§impl Helper
impl Helper
pub const DIGIT_0: u8 = 48u8
Sourcepub fn is_token(b: u8) -> bool
pub fn is_token(b: u8) -> bool
Determines if byte is a token char.
token = 1*tchar tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA ; any VCHAR, except delimiters
pub fn is_status_token(b: u8) -> bool
pub fn is_alpha(b: u8) -> bool
pub fn is_digit(b: u8) -> bool
pub fn is_hex(b: u8) -> bool
pub fn convert_hex(b: u8) -> Option<u8>
pub fn is_uri_token(b: u8) -> bool
pub fn skip_new_line<B: Bt>(buffer: &mut B) -> WebResult<()>
pub fn parse_chunk_data<'a, B: Bt>( buffer: &'a mut B, ) -> WebResult<(usize, usize)>
pub fn encode_chunk_data<B: Bt + BtMut>( buffer: &mut B, data: &[u8], ) -> Result<usize>
Sourcepub fn hex_to_vec(s: &str) -> Vec<u8> ⓘ
pub fn hex_to_vec(s: &str) -> Vec<u8> ⓘ
Examples found in repository?
examples/http2.rs (line 11)
8fn parse_header() {
9 let mut decoder = Decoder::new();
10 // C.4.1
11 let buf = Helper::hex_to_vec("8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 ff");
12 let buf_len = buf.len();
13 let mut header = Headers::empty();
14 let size = header
15 .parse(
16 BinaryMut::from(buf),
17 &mut decoder,
18 DEFAULT_SETTINGS_HEADER_TABLE_SIZE,
19 )
20 .unwrap();
21 assert!(size == buf_len);
22 assert!(header.method() == &Some(Method::Get));
23 assert!(header.path() == &Some("/".to_string()));
24 assert!(header.scheme() == &Some(Scheme::Http));
25 assert!(header.authority() == &Some("www.example.com".to_string()));
26
27 // C.4.2
28 let buf = Helper::hex_to_vec("8286 84be 5886 a8eb 1064 9cbf");
29 let buf_len = buf.len();
30 let mut header = Headers::empty();
31 let size = header
32 .parse(
33 BinaryMut::from(buf),
34 &mut decoder,
35 DEFAULT_SETTINGS_HEADER_TABLE_SIZE,
36 )
37 .unwrap();
38 assert!(size == buf_len);
39 assert!(header.method() == &Some(Method::Get));
40 assert!(header.path() == &Some("/".to_string()));
41 assert!(header.scheme() == &Some(Scheme::Http));
42 assert!(header.authority() == &Some("www.example.com".to_string()));
43 assert!(header.fields()["cache-control"] == "no-cache");
44
45 // C.4.3
46 let buf = Helper::hex_to_vec("8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 a849 e95b b8e8 b4bf ");
47 let buf_len = buf.len();
48 let mut header = Headers::empty();
49 let size = header
50 .parse(
51 BinaryMut::from(buf),
52 &mut decoder,
53 DEFAULT_SETTINGS_HEADER_TABLE_SIZE,
54 )
55 .unwrap();
56 assert!(size == buf_len);
57 assert!(header.method() == &Some(Method::Get));
58 assert!(header.path() == &Some("/index.html".to_string()));
59 assert!(header.scheme() == &Some(Scheme::Https));
60 assert!(header.authority() == &Some("www.example.com".to_string()));
61 assert!(header.fields()["custom-key"] == "custom-value");
62}pub fn eq_bytes_ignore_ascii_case(a: &[u8], b: &[u8]) -> bool
pub fn eq_bytes(a: &[u8], b: &[u8]) -> bool
pub fn contains_bytes(a: &[u8], b: &[u8]) -> bool
Auto Trait Implementations§
impl Freeze for Helper
impl RefUnwindSafe for Helper
impl Send for Helper
impl Sync for Helper
impl Unpin for Helper
impl UnwindSafe for Helper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more