| 1 | use superrust-analyzer cargo mediatype 0.23.0 crate/::{errorrust-analyzer cargo mediatype 0.23.0 error/::*, namerust-analyzer cargo mediatype 0.23.0 name/::*}; |
| 2 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{boxedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/::Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#}; |
| 3 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{numrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/::NonZeroU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU8#, opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#}; |
| 4 | |
| 5 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 6 | pub struct Indicesrust-analyzer cargo mediatype 0.23.0 parse/Indices# { |
| 7 | tyrust-analyzer cargo mediatype 0.23.0 parse/Indices#ty.: NonZeroU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU8#, |
| 8 | subtyrust-analyzer cargo mediatype 0.23.0 parse/Indices#subty.: NonZeroU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU8#, |
| 9 | suffixrust-analyzer cargo mediatype 0.23.0 parse/Indices#suffix.: u8, |
| 10 | paramsrust-analyzer cargo mediatype 0.23.0 parse/Indices#params.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[[usize; 4]]>, |
| 11 | } |
| 12 | |
| 13 | impl Indicesrust-analyzer cargo mediatype 0.23.0 parse/Indices# { |
| 14 | pub const fn tyrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]ty().(&self) -> Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize> { |
| 15 | 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.tyrust-analyzer cargo mediatype 0.23.0 parse/Indices#ty..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() as _ |
| 16 | } |
| 17 | |
| 18 | pub const fn subtyrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]subty().(&self) -> Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize> { |
| 19 | let start = self.tyrust-analyzer cargo mediatype 0.23.0 parse/Indices#ty..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 20 | let end = start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().self.subtyrust-analyzer cargo mediatype 0.23.0 parse/Indices#subty..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() as usize; |
| 21 | start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end |
| 22 | } |
| 23 | |
| 24 | pub const fn suffixrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]suffix().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>> { |
| 25 | let start = self.tyrust-analyzer cargo mediatype 0.23.0 parse/Indices#ty..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().self.subtyrust-analyzer cargo mediatype 0.23.0 parse/Indices#subty..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 26 | let end = start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().self.suffixrust-analyzer cargo mediatype 0.23.0 parse/Indices#suffix. as usize; |
| 27 | if start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().end { |
| 28 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end) |
| 29 | } else { |
| 30 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | pub const fn paramsrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]params().(&self) -> &[[usize; 4]] { |
| 35 | &self.paramsrust-analyzer cargo mediatype 0.23.0 parse/Indices#params. |
| 36 | } |
| 37 | |
| 38 | pub fn parserust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]parse().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(Selfrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices], usize), MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#> { |
| 39 | let (ty, right) = match s.bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]bytes().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(Namerust-analyzer cargo mediatype 0.23.0 name/Name#::MAX_LENGTHrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]MAX_LENGTH. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1).positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#position().(|b| b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'/') { |
| 40 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(slash) => (&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#slash]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().slash rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().), |
| 41 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 42 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidTypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidTypeName#); |
| 43 | } |
| 44 | }; |
| 45 | |
| 46 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_restricted_namerust-analyzer cargo mediatype 0.23.0 parse/is_restricted_name().(ty) { |
| 47 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidTypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidTypeName#); |
| 48 | } |
| 49 | |
| 50 | let suffix_end = right |
| 51 | .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().(|c: char| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_restricted_charrust-analyzer cargo mediatype 0.23.0 parse/is_restricted_char().(c)) |
| 52 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()); |
| 53 | let suffix_start = right[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#suffix_end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..rfindrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]rfind().('+'); |
| 54 | |
| 55 | let (subty, suffix) = suffix_start.map_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or_else().( |
| 56 | || (&right[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#suffix_end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., ""), |
| 57 | |suffix_start| (&right[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#suffix_start]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &right[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().suffix_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#suffix_end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().), |
| 58 | ); |
| 59 | |
| 60 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_restricted_namerust-analyzer cargo mediatype 0.23.0 parse/is_restricted_name().(subty) { |
| 61 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidSubtypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidSubtypeName#); |
| 62 | } |
| 63 | |
| 64 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().suffix.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_restricted_namerust-analyzer cargo mediatype 0.23.0 parse/is_restricted_name().(suffix) { |
| 65 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidSuffixrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidSuffix#); |
| 66 | } |
| 67 | |
| 68 | let sub_end = ty.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().subty.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().(); |
| 69 | let params_start = sub_end |
| 70 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().if suffix.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 71 | 0 |
| 72 | } else { |
| 73 | suffix.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 |
| 74 | }; |
| 75 | |
| 76 | let (mut params, params_len) = parse_paramsrust-analyzer cargo mediatype 0.23.0 parse/parse_params().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().params_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 77 | for elem in &mut params { |
| 78 | for v in elem.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() { |
| 79 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().params_start; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(( |
| 84 | Selfrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices] { |
| 85 | tyrust-analyzer cargo mediatype 0.23.0 parse/Indices#ty.: NonZeroU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU8#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(ty.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().().try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 86 | subtyrust-analyzer cargo mediatype 0.23.0 parse/Indices#subty.: NonZeroU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU8#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(subty.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().().try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 87 | suffixrust-analyzer cargo mediatype 0.23.0 parse/Indices#suffix.: suffix.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().().try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 88 | paramsrust-analyzer cargo mediatype 0.23.0 parse/Indices#params.: params.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().(), |
| 89 | }, |
| 90 | params_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().params_len, |
| 91 | )) |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | #[cfg(test)] |
| 96 | fn parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#> { |
| 97 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#; |
| 98 | |
| 99 | let mut out = allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 100 | let (indices, _) = Indicesrust-analyzer cargo mediatype 0.23.0 parse/Indices#::parserust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]parse().(s)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 101 | |
| 102 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(out, "{}/{}", &s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().indices.tyrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]ty().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().indices.subtyrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]subty().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 103 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(suffix) = indices.suffixrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]suffix().() { |
| 104 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(out, "+{}", &s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().suffix]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 105 | } |
| 106 | for param in indices.paramsrust-analyzer cargo mediatype 0.23.0 parse/impl#[Indices]params().() { |
| 107 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 108 | out, |
| 109 | "; {}={}", |
| 110 | &s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().param[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...param[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., |
| 111 | &s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().param[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...param[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 112 | ) |
| 113 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 114 | } |
| 115 | |
| 116 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(out) |
| 117 | } |
| 118 | |
| 119 | pub fn is_restricted_namerust-analyzer cargo mediatype 0.23.0 parse/is_restricted_name().(s: &str) -> bool { |
| 120 | s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().Namerust-analyzer cargo mediatype 0.23.0 name/Name#::MAX_LENGTHrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]MAX_LENGTH. |
| 121 | && s.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().(|c: char| c.is_ascii_alphanumericrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii_alphanumeric().() || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'*') |
| 122 | && is_restricted_strrust-analyzer cargo mediatype 0.23.0 parse/is_restricted_str().(s) |
| 123 | } |
| 124 | |
| 125 | pub fn is_restricted_strrust-analyzer cargo mediatype 0.23.0 parse/is_restricted_str().(s: &str) -> bool { |
| 126 | s.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(is_restricted_charrust-analyzer cargo mediatype 0.23.0 parse/is_restricted_char().) |
| 127 | } |
| 128 | |
| 129 | pub fn is_restricted_charrust-analyzer cargo mediatype 0.23.0 parse/is_restricted_char().(c: char) -> bool { |
| 130 | c.is_ascii_alphanumericrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii_alphanumeric().() |
| 131 | || matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 132 | c, |
| 133 | '!' | '#' | '$' | '&' | '-' | '^' | '_' | '.' | '+' | '%' | '*' | '\'' |
| 134 | ) |
| 135 | } |
| 136 | |
| 137 | pub const fn is_owsrust-analyzer cargo mediatype 0.23.0 parse/is_ows().(c: char) -> bool { |
| 138 | c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().' ' || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'\t' |
| 139 | } |
| 140 | |
| 141 | fn parse_paramsrust-analyzer cargo mediatype 0.23.0 parse/parse_params().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<[usize; 4]>, usize), MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#> { |
| 142 | let mut vec = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 143 | let mut offset = 0; |
| 144 | let mut len = 0; |
| 145 | |
| 146 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((name, value)) = parse_paramrust-analyzer cargo mediatype 0.23.0 parse/parse_param().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().offset..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 147 | vec.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().([ |
| 148 | offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().name.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start., |
| 149 | offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().name.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end., |
| 150 | offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().value.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start., |
| 151 | offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().value.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end., |
| 152 | ]); |
| 153 | len = offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().value.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.; |
| 154 | offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().value.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.; |
| 155 | } |
| 156 | |
| 157 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((vec, len)) |
| 158 | } |
| 159 | |
| 160 | type ParamRangerust-analyzer cargo mediatype 0.23.0 parse/ParamRange# = (Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>); |
| 161 | |
| 162 | fn parse_paramrust-analyzer cargo mediatype 0.23.0 parse/parse_param().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<ParamRangerust-analyzer cargo mediatype 0.23.0 parse/ParamRange#>, MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#> { |
| 163 | let (ows, right) = match s.split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().(';') { |
| 164 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((ows, right)) if ows.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(is_owsrust-analyzer cargo mediatype 0.23.0 parse/is_ows().) && right.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(is_owsrust-analyzer cargo mediatype 0.23.0 parse/is_ows().) => { |
| 165 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 166 | } |
| 167 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((ows, right)) if ows.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(is_owsrust-analyzer cargo mediatype 0.23.0 parse/is_ows().) => (ows, right), |
| 168 | _ if s.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(is_owsrust-analyzer cargo mediatype 0.23.0 parse/is_ows().) => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 169 | _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamsrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParams#), |
| 170 | }; |
| 171 | |
| 172 | let (name, value) = match right.split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().('=') { |
| 173 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pair) => pair, |
| 174 | _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamsrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParams#), |
| 175 | }; |
| 176 | |
| 177 | let key_trimmed = name.trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().(is_owsrust-analyzer cargo mediatype 0.23.0 parse/is_ows().).lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().(); |
| 178 | let key_start = ows.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().name.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().key_trimmed; |
| 179 | let key_range = key_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#key_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().key_trimmed; |
| 180 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_restricted_namerust-analyzer cargo mediatype 0.23.0 parse/is_restricted_name().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().key_range.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`][Clone]clone().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) { |
| 181 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParamName#); |
| 182 | } |
| 183 | |
| 184 | let value_start = key_range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 185 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value) = value.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('\"') { |
| 186 | let value_end = value_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().parse_quoted_valuerust-analyzer cargo mediatype 0.23.0 parse/parse_quoted_value().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 187 | let value_range = value_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#value_end; |
| 188 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((key_range, value_range))) |
| 189 | } else { |
| 190 | let value_end = value_start |
| 191 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().value |
| 192 | .charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().() |
| 193 | .take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|&c| is_restricted_charrust-analyzer cargo mediatype 0.23.0 parse/is_restricted_char().(c)) |
| 194 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(char::len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().) |
| 195 | .sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().::<usize>(); |
| 196 | let value_range = value_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#value_end; |
| 197 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((key_range, value_range))) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | pub fn parse_quoted_valuerust-analyzer cargo mediatype 0.23.0 parse/parse_quoted_value().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#> { |
| 202 | let mut len = 0; |
| 203 | let mut escaped = false; |
| 204 | for c in s.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().() { |
| 205 | len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().c.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().(); |
| 206 | match c { |
| 207 | _ if escaped => { |
| 208 | escaped = false; |
| 209 | } |
| 210 | '\\' => { |
| 211 | escaped = true; |
| 212 | } |
| 213 | '"' => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(len), |
| 214 | // RFC 7230 §3.2.6: qdtext excludes all CTLs except HTAB; CR and LF are |
| 215 | // both forbidden. Rejecting '\r' alongside '\n' closes a CRLF-injection |
| 216 | // vector (raw CR was accepted by the catch-all below and round-tripped |
| 217 | // verbatim through Display on re-serialization). |
| 218 | '\n' | '\r' => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamValuerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParamValue#), |
| 219 | _ => (), |
| 220 | } |
| 221 | } |
| 222 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamValuerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParamValue#) |
| 223 | } |
| 224 | |
| 225 | #[cfg(test)] |
| 226 | mod testsrust-analyzer cargo mediatype 0.23.0 parse/tests/ { |
| 227 | use superrust-analyzer cargo mediatype 0.23.0 parse/::*; |
| 228 | |
| 229 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 230 | fn parserust-analyzer cargo mediatype 0.23.0 parse/tests/parse().() { |
| 231 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("*/*"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("*/*".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 232 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("text/plain".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 233 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain;"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("text/plain".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 234 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+xml"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+xml".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 235 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+x"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+x".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 236 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("a/b+c+d"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("a/b+c+d".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 237 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 238 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+xml;"), |
| 239 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+xml".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 240 | ); |
| 241 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 242 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+xml; charset=UTF-8"), |
| 243 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+xml; charset=UTF-8".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 244 | ); |
| 245 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 246 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+xml; charset=UTF-8;"), |
| 247 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+xml; charset=UTF-8".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 248 | ); |
| 249 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 250 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+xml; charset=US-ASCII; charset=UTF-8;"), |
| 251 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+xml; charset=US-ASCII; charset=UTF-8".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 252 | ); |
| 253 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 254 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+xml; charset=US-ASCII; hello=WORLD; charset=UTF-8;"), |
| 255 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+xml; charset=US-ASCII; hello=WORLD; charset=UTF-8".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 256 | ); |
| 257 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 258 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+xml ; charset=UTF-8 "), |
| 259 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+xml; charset=UTF-8".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 260 | ); |
| 261 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 262 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+xml; charset=\"UTF-8\""), |
| 263 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+xml; charset=\"UTF-8\"".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 264 | ); |
| 265 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 266 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("image/svg+xml; charset=\"UT\\\"F-8\""), |
| 267 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("image/svg+xml; charset=\"UT\\\"F-8\"".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 268 | ); |
| 269 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 270 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("multipart/form-data ; boundary=--boundary13234"), |
| 271 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("multipart/form-data; boundary=--boundary13234".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 272 | ); |
| 273 | |
| 274 | let s = "text/plain"; |
| 275 | let long_str = [s, ";", &" ".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().())].concatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]concat().(); |
| 276 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().(&long_str), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("text/plain".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 277 | |
| 278 | let long_name = "a".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(Namerust-analyzer cargo mediatype 0.23.0 name/Name#::MAX_LENGTHrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]MAX_LENGTH.); |
| 279 | let long_str = [&long_name, "/", &long_name, "+", &long_name].concatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]concat().(); |
| 280 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().(&long_str), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(long_str)); |
| 281 | } |
| 282 | |
| 283 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 284 | fn parse_errorrust-analyzer cargo mediatype 0.23.0 parse/tests/parse_error().() { |
| 285 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().(""), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidTypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidTypeName#)); |
| 286 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 287 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("textplain"), |
| 288 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidTypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidTypeName#) |
| 289 | ); |
| 290 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 291 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text//plain"), |
| 292 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidSubtypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidSubtypeName#) |
| 293 | ); |
| 294 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 295 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().(" text/plain"), |
| 296 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidTypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidTypeName#) |
| 297 | ); |
| 298 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 299 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; charsetUTF-8"), |
| 300 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamsrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParams#) |
| 301 | ); |
| 302 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 303 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain;;"), |
| 304 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamsrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParams#) |
| 305 | ); |
| 306 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 307 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain;;;"), |
| 308 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamsrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParams#) |
| 309 | ); |
| 310 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 311 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; charset=\"UTF-8"), |
| 312 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamValuerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParamValue#) |
| 313 | ); |
| 314 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 315 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; charset==UTF-8"), |
| 316 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamsrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParams#) |
| 317 | ); |
| 318 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 319 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; \r\n charset=UTF-8;"), |
| 320 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParamName#) |
| 321 | ); |
| 322 | |
| 323 | let long_str = [&"t".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as usize), "/plain"].concatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]concat().(); |
| 324 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 325 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().(&long_str), |
| 326 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidTypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidTypeName#) |
| 327 | ); |
| 328 | let multibyte_str = "a\u{FFFF}".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(Namerust-analyzer cargo mediatype 0.23.0 name/Name#::MAX_LENGTHrust-analyzer cargo mediatype 0.23.0 name/impl#[`Name<'a>`]MAX_LENGTH.); |
| 329 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 330 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().(&multibyte_str), |
| 331 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidTypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidTypeName#) |
| 332 | ); |
| 333 | |
| 334 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 335 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("текст/plain"), |
| 336 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidTypeNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidTypeName#) |
| 337 | ); |
| 338 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 339 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; кодування=UTF-8"), |
| 340 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamNamerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParamName#) |
| 341 | ); |
| 342 | } |
| 343 | |
| 344 | // RFC 7230 §3.2.6: qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text; |
| 345 | // all CTLs except HTAB are excluded from a quoted-string value. CR and LF are |
| 346 | // both forbidden — the parser must reject them symmetrically (an incomplete |
| 347 | // CTL filter that rejects only LF and admits CR is a CRLF-injection vector: |
| 348 | // the parsed MediaType borrows the input, so a raw CR is round-tripped |
| 349 | // verbatim through Display on re-serialization into an HTTP header). |
| 350 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 351 | fn parse_quoted_value_ctl_filterrust-analyzer cargo mediatype 0.23.0 parse/tests/parse_quoted_value_ctl_filter().() { |
| 352 | // HTAB is the only CTL allowed in qdtext (RFC 7230 §3.2.6) — must parse. |
| 353 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 354 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; x=\"foo\tbar\""), |
| 355 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("text/plain; x=\"foo\tbar\"".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 356 | ); |
| 357 | // SP is valid qdtext — must parse. |
| 358 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 359 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; x=\"foo bar\""), |
| 360 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("text/plain; x=\"foo bar\"".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 361 | ); |
| 362 | // A regular VCHAR quoted value — must parse (control). |
| 363 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 364 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; charset=\"UTF-8\""), |
| 365 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("text/plain; charset=\"UTF-8\"".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 366 | ); |
| 367 | // Raw CR inside a quoted value is invalid qdtext — must be rejected. |
| 368 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 369 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; x=\"foo\rbar\""), |
| 370 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamValuerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParamValue#) |
| 371 | ); |
| 372 | // Raw LF inside a quoted value is invalid qdtext — must be rejected |
| 373 | // (symmetry with the CR case: RFC 7230 treats CR and LF identically). |
| 374 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 375 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; x=\"foo\nbar\""), |
| 376 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamValuerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParamValue#) |
| 377 | ); |
| 378 | // CRLF inside a quoted value — must be rejected (CR is hit first). |
| 379 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 380 | parse_to_stringrust-analyzer cargo mediatype 0.23.0 parse/parse_to_string().("text/plain; x=\"foo\r\nbar\""), |
| 381 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MediaTypeErrorrust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#::InvalidParamValuerust-analyzer cargo mediatype 0.23.0 error/MediaTypeError#InvalidParamValue#) |
| 382 | ); |
| 383 | } |
| 384 | } |