rocket_http/parse/uri/
mod.rs1mod parser;
2mod error;
3pub(crate) mod tables;
4
5#[cfg(test)] mod tests;
6
7use crate::uri::{Uri, Origin, Absolute, Authority, Reference, Asterisk};
8
9use self::parser::*;
10
11pub use self::error::Error;
12
13type RawInput<'a> = pear::input::Pear<pear::input::Cursor<&'a [u8]>>;
14
15#[inline]
16pub fn from_str(s: &str) -> Result<Uri<'_>, Error<'_>> {
17 Ok(parse!(uri: RawInput::new(s.as_bytes()))?)
18}
19
20#[inline]
21pub fn origin_from_str(s: &str) -> Result<Origin<'_>, Error<'_>> {
22 Ok(parse!(origin: RawInput::new(s.as_bytes()))?)
23}
24
25#[inline]
26pub fn authority_from_str(s: &str) -> Result<Authority<'_>, Error<'_>> {
27 Ok(parse!(authority: RawInput::new(s.as_bytes()))?)
28}
29
30#[inline]
31pub fn authority_from_bytes(s: &[u8]) -> Result<Authority<'_>, Error<'_>> {
32 Ok(parse!(authority: RawInput::new(s))?)
33}
34
35#[inline]
36pub fn scheme_from_str(s: &str) -> Result<&str, Error<'_>> {
37 let _validated = parse!(scheme: RawInput::new(s.as_bytes()))?;
38 Ok(s)
39}
40
41#[inline]
42pub fn absolute_from_str(s: &str) -> Result<Absolute<'_>, Error<'_>> {
43 Ok(parse!(absolute: RawInput::new(s.as_bytes()))?)
44}
45
46#[inline]
47pub fn asterisk_from_str(s: &str) -> Result<Asterisk, Error<'_>> {
48 Ok(parse!(asterisk: RawInput::new(s.as_bytes()))?)
49}
50
51#[inline]
52pub fn reference_from_str(s: &str) -> Result<Reference<'_>, Error<'_>> {
53 Ok(parse!(reference: RawInput::new(s.as_bytes()))?)
54}