| 1 | use craterust-analyzer cargo fluent-uri 0.4.1 crate/::{ |
| 2 | imprust-analyzer cargo fluent-uri 0.4.1 imp/::{AuthMetarust-analyzer cargo fluent-uri 0.4.1 imp/AuthMeta#, Constraintsrust-analyzer cargo fluent-uri 0.4.1 imp/Constraints#, HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#, Metarust-analyzer cargo fluent-uri 0.4.1 imp/Meta#}, |
| 3 | pct_encrust-analyzer cargo fluent-uri 0.4.1 pct_enc/::{tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/::*, Tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/Table#, OCTET_TABLE_LOrust-analyzer cargo fluent-uri 0.4.1 pct_enc/OCTET_TABLE_LO.}, |
| 4 | utf8rust-analyzer cargo fluent-uri 0.4.1 utf8/, |
| 5 | }; |
| 6 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{ |
| 7 | numrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/::NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#, |
| 8 | opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut#}, |
| 9 | strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/, |
| 10 | }; |
| 11 | |
| 12 | /// Detailed cause of a [`ParseError`]. |
| 13 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 14 | pub enum ParseErrorKindrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind# { |
| 15 | /// Invalid percent-encoded octet that is either non-hexadecimal or incomplete. |
| 16 | /// |
| 17 | /// The error index points to the percent character "%" of the octet. |
| 18 | InvalidPctEncodedOctetrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#InvalidPctEncodedOctet#, |
| 19 | /// Unexpected character that is not allowed by the URI/IRI syntax. |
| 20 | /// |
| 21 | /// The error index points to the first byte of the character. |
| 22 | UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#, |
| 23 | /// Invalid IPv6 address. |
| 24 | /// |
| 25 | /// The error index points to the first byte of the address. |
| 26 | InvalidIpv6Addrrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#InvalidIpv6Addr#, |
| 27 | } |
| 28 | |
| 29 | /// An error occurred when parsing a URI/IRI (reference). |
| 30 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 31 | pub struct ParseErrorrust-analyzer cargo fluent-uri 0.4.1 parse/ParseError# { |
| 32 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) indexrust-analyzer cargo fluent-uri 0.4.1 parse/ParseError#index.: usize, |
| 33 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) kindrust-analyzer cargo fluent-uri 0.4.1 parse/ParseError#kind.: ParseErrorKindrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#, |
| 34 | } |
| 35 | |
| 36 | impl ParseErrorrust-analyzer cargo fluent-uri 0.4.1 parse/ParseError# { |
| 37 | /// Returns the index at which the error occurred. |
| 38 | #[must_use] |
| 39 | pub fn indexrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[ParseError]index().(&self) -> usize { |
| 40 | self.indexrust-analyzer cargo fluent-uri 0.4.1 parse/ParseError#index. |
| 41 | } |
| 42 | |
| 43 | /// Returns the detailed cause of the error. |
| 44 | #[must_use] |
| 45 | pub fn kindrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[ParseError]kind().(&self) -> ParseErrorKindrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind# { |
| 46 | self.kindrust-analyzer cargo fluent-uri 0.4.1 parse/ParseError#kind. |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | #[cfg(feature = "impl-error")] |
| 51 | impl craterust-analyzer cargo fluent-uri 0.4.1 crate/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for ParseErrorrust-analyzer cargo fluent-uri 0.4.1 parse/ParseError# {} |
| 52 | |
| 53 | type Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<T> = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, craterust-analyzer cargo fluent-uri 0.4.1 crate/::parserust-analyzer cargo fluent-uri 0.4.1 parse/::ParseErrorrust-analyzer cargo fluent-uri 0.4.1 parse/ParseError#>; |
| 54 | |
| 55 | /// Returns immediately with an error. |
| 56 | macro_rules! errrust-analyzer cargo fluent-uri 0.4.1 parse/err! { |
| 57 | ($index:expr, $kind:ident) => { |
| 58 | return Err(crate::parse::ParseError { |
| 59 | index: $index, |
| 60 | kind: crate::parse::ParseErrorKind::$kind, |
| 61 | }) |
| 62 | }; |
| 63 | } |
| 64 | |
| 65 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) fn parserust-analyzer cargo fluent-uri 0.4.1 parse/parse().(bytes: &[u8], constraints: Constraintsrust-analyzer cargo fluent-uri 0.4.1 imp/Constraints#) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<Metarust-analyzer cargo fluent-uri 0.4.1 imp/Meta#> { |
| 66 | let mut parser = Parserrust-analyzer cargo fluent-uri 0.4.1 parse/Parser# { |
| 67 | constraintsrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#constraints., |
| 68 | readerrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#reader.: Readerrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#::newrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]new().(bytes), |
| 69 | outrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#out.: Metarust-analyzer cargo fluent-uri 0.4.1 imp/Meta#::defaultrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[Meta][Default]default().(), |
| 70 | }; |
| 71 | parser.parse_from_schemerust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]parse_from_scheme().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 72 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(parser.outrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#out.) |
| 73 | } |
| 74 | |
| 75 | /// URI/IRI parser. |
| 76 | /// |
| 77 | /// # Invariants |
| 78 | /// |
| 79 | /// `pos <= len`, `pos` is non-decreasing and on the boundary of a UTF-8 code point. |
| 80 | /// |
| 81 | /// # Preconditions and guarantees |
| 82 | /// |
| 83 | /// Before parsing, ensure that `pos == 0`, `out` is default initialized |
| 84 | /// and `bytes` is valid UTF-8. |
| 85 | /// |
| 86 | /// Start and finish parsing by calling `parse_from_scheme`. |
| 87 | /// The following are guaranteed when parsing succeeds: |
| 88 | /// |
| 89 | /// - All output indexes are within bounds, correctly ordered |
| 90 | /// and on the boundary of a UTF-8 code point. |
| 91 | /// - All URI/IRI components defined by output indexes are validated. |
| 92 | struct Parserrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#<'a> { |
| 93 | constraintsrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#constraints.: Constraintsrust-analyzer cargo fluent-uri 0.4.1 imp/Constraints#, |
| 94 | readerrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#reader.: Readerrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#<'a>, |
| 95 | outrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#out.: Metarust-analyzer cargo fluent-uri 0.4.1 imp/Meta#, |
| 96 | } |
| 97 | |
| 98 | struct Readerrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#<'a> { |
| 99 | bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes.: &'a [u8], |
| 100 | posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.: usize, |
| 101 | } |
| 102 | |
| 103 | impl<'a> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for Parserrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#<'a> { |
| 104 | type Targetrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'a>`][Deref]Target# = Readerrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#<'a>; |
| 105 | |
| 106 | fn derefrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'a>`][Deref]deref().(&self) -> &Selfrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'a>`][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 107 | &self.readerrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#reader. |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | impl DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut# for Parserrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#<'_> { |
| 112 | fn deref_mutrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`][DerefMut]deref_mut().(&mut self) -> &mut Selfrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`][DerefMut]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 113 | &mut self.readerrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#reader. |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | enum PathKindrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind# { |
| 118 | Generalrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#General#, |
| 119 | AbEmptyrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#AbEmpty#, |
| 120 | ContinuedNoSchemerust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#ContinuedNoScheme#, |
| 121 | } |
| 122 | |
| 123 | enum Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg# { |
| 124 | // *1":" 1*4HEXDIG |
| 125 | Normalrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#Normal#(u16, bool), |
| 126 | // "::" |
| 127 | Ellipsisrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#Ellipsis#, |
| 128 | // *1":" 1*4HEXDIG "." |
| 129 | MaybeV4rust-analyzer cargo fluent-uri 0.4.1 parse/Seg#MaybeV4#(bool), |
| 130 | // ":" |
| 131 | SingleColonrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#SingleColon#, |
| 132 | } |
| 133 | |
| 134 | impl<'a> Readerrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#<'a> { |
| 135 | fn newrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]new().(bytes: &'a [u8]) -> Selfrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`] { |
| 136 | Readerrust-analyzer cargo fluent-uri 0.4.1 parse/Reader# { bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes., posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.: 0 } |
| 137 | } |
| 138 | |
| 139 | fn lenrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]len().(&self) -> usize { |
| 140 | self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 141 | } |
| 142 | |
| 143 | fn has_remainingrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]has_remaining().(&self) -> bool { |
| 144 | self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. 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().self.lenrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]len().() |
| 145 | } |
| 146 | |
| 147 | fn peekrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek().(&self, i: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> { |
| 148 | self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. 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().i).copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().() |
| 149 | } |
| 150 | |
| 151 | // Any call to this method must keep the invariants. |
| 152 | fn skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(&mut self, n: usize) { |
| 153 | // INVARIANT: `pos` is non-decreasing. |
| 154 | self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. 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().n; |
| 155 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. <= self.lenrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]len().()); |
| 156 | } |
| 157 | |
| 158 | // Returns `true` iff any byte is read. |
| 159 | fn readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(&mut self, table: &Tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/Table#) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<bool> { |
| 160 | let start = self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.; |
| 161 | self._readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]_read().(table, |_, _| {})?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 162 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().start) |
| 163 | } |
| 164 | |
| 165 | fn _readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]_read().(&mut self, table: &Tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/Table#, mut f: impl FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(usize, u32)) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<()> { |
| 166 | let mut i = self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.; |
| 167 | let allow_pct_encoded = table.allows_pct_encodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows_pct_encoded().(); |
| 168 | let allow_non_ascii = table.allows_non_asciirust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows_non_ascii().(); |
| 169 | |
| 170 | while i 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().self.lenrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]len().() { |
| 171 | let x = self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 172 | if allow_pct_encoded && x 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'%' { |
| 173 | let [hi, lo, ..] = self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i 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(). else { |
| 174 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(i, InvalidPctEncodedOctetrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#InvalidPctEncodedOctet#); |
| 175 | }; |
| 176 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(HEXDIGrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/HEXDIG..allows_asciirust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows_ascii().(hi) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][`BitAnd<Self>`]bitand().HEXDIGrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/HEXDIG..allows_asciirust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows_ascii().(lo)) { |
| 177 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(i, InvalidPctEncodedOctetrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#InvalidPctEncodedOctet#); |
| 178 | } |
| 179 | i 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().3; |
| 180 | } else if allow_non_ascii { |
| 181 | let (x, len) = utf8rust-analyzer cargo fluent-uri 0.4.1 utf8/::next_code_pointrust-analyzer cargo fluent-uri 0.4.1 utf8/next_code_point().(self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes., i); |
| 182 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().table.allows_code_pointrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows_code_point().(x) { |
| 183 | break; |
| 184 | } |
| 185 | f(i, x); |
| 186 | i 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().len; |
| 187 | } else { |
| 188 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().table.allows_asciirust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows_ascii().(x) { |
| 189 | break; |
| 190 | } |
| 191 | f(i, x as u32); |
| 192 | i 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().1; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | // INVARIANT: `i` is non-decreasing. |
| 197 | self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. = i; |
| 198 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 199 | } |
| 200 | |
| 201 | fn read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().(&mut self, s: &str) -> bool { |
| 202 | if self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos...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()..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]starts_with().(s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) { |
| 203 | // INVARIANT: The remaining bytes start with `s` so it's fine to skip `s.len()`. |
| 204 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()); |
| 205 | true |
| 206 | } else { |
| 207 | false |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | fn read_v6rust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v6().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<[u16; 8]> { |
| 212 | let mut segs = [0; 8]; |
| 213 | let mut ellipsis_i = 8; |
| 214 | |
| 215 | let mut i = 0; |
| 216 | while i 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().8 { |
| 217 | match self.read_v6_segmentrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v6_segment().() { |
| 218 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#::Normalrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#Normal#(seg, colon)) => { |
| 219 | if colon rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[bool][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[bool][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[bool][`PartialEq<Self>`]eq().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 || i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().ellipsis_i) { |
| 220 | // Leading colon, triple colons, or no colon. |
| 221 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 222 | } |
| 223 | segs[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = seg; |
| 224 | i 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().1; |
| 225 | } |
| 226 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#::Ellipsisrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#Ellipsis#) => { |
| 227 | if ellipsis_i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().8 { |
| 228 | // Multiple ellipses. |
| 229 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 230 | } |
| 231 | ellipsis_i = i; |
| 232 | } |
| 233 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#::MaybeV4rust-analyzer cargo fluent-uri 0.4.1 parse/Seg#MaybeV4#(colon)) => { |
| 234 | if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().6 || colon rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[bool][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[bool][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[bool][`PartialEq<Self>`]eq().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().ellipsis_i) { |
| 235 | // Not enough space, triple colons, or no colon. |
| 236 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 237 | } |
| 238 | let octets = self.read_v4rust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v4().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch()..to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_be_bytes().(); |
| 239 | segs[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = u16::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_be_bytes().([octets[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()., octets[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().]); |
| 240 | segs[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().i 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 array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = u16::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_be_bytes().([octets[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()., octets[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().]); |
| 241 | i 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().2; |
| 242 | break; |
| 243 | } |
| 244 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#::SingleColonrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#SingleColon#) => return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 245 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => break, |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | if ellipsis_i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().8 { |
| 250 | // No ellipsis. |
| 251 | if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().8 { |
| 252 | // Too short. |
| 253 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 254 | } |
| 255 | } else if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().8 { |
| 256 | // Eliding nothing. |
| 257 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 258 | } else { |
| 259 | // Shift the segments after the ellipsis to the right. |
| 260 | for j in (ellipsis_i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#i).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() { |
| 261 | segs[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().8 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().(i 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().j)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = segs[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().j]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().; |
| 262 | segs[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().j]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = 0; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(segs) |
| 267 | } |
| 268 | |
| 269 | fn read_v6_segmentrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v6_segment().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#> { |
| 270 | let colon = self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().(":"); |
| 271 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.has_remainingrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]has_remaining().() { |
| 272 | return colon.then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#::SingleColonrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#SingleColon#); |
| 273 | } |
| 274 | |
| 275 | let first = self.peekrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 276 | let mut x = match OCTET_TABLE_LOrust-analyzer cargo fluent-uri 0.4.1 pct_enc/OCTET_TABLE_LO.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().first as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). { |
| 277 | v if v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().128 => v as u16, |
| 278 | _ => { |
| 279 | return colon.thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| { |
| 280 | if first 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':' { |
| 281 | // INVARIANT: Skipping ":" is fine. |
| 282 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(1); |
| 283 | Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#::Ellipsisrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#Ellipsis# |
| 284 | } else { |
| 285 | Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#::SingleColonrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#SingleColon# |
| 286 | } |
| 287 | }); |
| 288 | } |
| 289 | }; |
| 290 | let mut i = 1; |
| 291 | |
| 292 | while i 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().4 { |
| 293 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b) = self.peekrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek().(i) else { |
| 294 | // INVARIANT: Skipping `i` hexadecimal digits is fine. |
| 295 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(i); |
| 296 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 297 | }; |
| 298 | match OCTET_TABLE_LOrust-analyzer cargo fluent-uri 0.4.1 pct_enc/OCTET_TABLE_LO.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().b as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). { |
| 299 | v if v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().128 => { |
| 300 | x = (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shl<i32>`]shl().4) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`BitOr<Self>`]bitor().v as u16; |
| 301 | i 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().1; |
| 302 | continue; |
| 303 | } |
| 304 | _ if 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'.' => return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#::MaybeV4rust-analyzer cargo fluent-uri 0.4.1 parse/Seg#MaybeV4#(colon)), |
| 305 | _ => break, |
| 306 | } |
| 307 | } |
| 308 | // INVARIANT: Skipping `i` hexadecimal digits is fine. |
| 309 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(i); |
| 310 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Segrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#::Normalrust-analyzer cargo fluent-uri 0.4.1 parse/Seg#Normal#(x, colon)) |
| 311 | } |
| 312 | |
| 313 | fn read_v4rust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v4().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32> { |
| 314 | let mut addr = self.read_v4_octetrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v4_octet().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().24; |
| 315 | for i in (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() { |
| 316 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().(".") { |
| 317 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 318 | } |
| 319 | addr rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOrAssign<Self>`]bitor_assign().self.read_v4_octetrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v4_octet().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().8); |
| 320 | } |
| 321 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(addr) |
| 322 | } |
| 323 | |
| 324 | fn read_v4_octetrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v4_octet().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32> { |
| 325 | let mut res = self.peek_digitrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek_digit().(0)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 326 | if res rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().0 { |
| 327 | // INVARIANT: Skipping "0" is fine. |
| 328 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(1); |
| 329 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(0); |
| 330 | } |
| 331 | |
| 332 | for i in 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3 { |
| 333 | let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = self.peek_digitrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek_digit().(i) else { |
| 334 | // INVARIANT: Skipping `i` digits is fine. |
| 335 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(i); |
| 336 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(res); |
| 337 | }; |
| 338 | res = res rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().10 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().x; |
| 339 | } |
| 340 | // INVARIANT: Skipping 3 digits is fine. |
| 341 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(3); |
| 342 | |
| 343 | u8::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u8][`TryFrom<u32>`]try_from().(res).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().().then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(res) |
| 344 | } |
| 345 | |
| 346 | fn peek_digitrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek_digit().(&self, i: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32> { |
| 347 | self.peekrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek().(i).and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|x| (x as char).to_digitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]to_digit().(10)) |
| 348 | } |
| 349 | |
| 350 | fn read_portrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_port().(&mut self) { |
| 351 | if self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().(":") { |
| 352 | let mut i = 0; |
| 353 | while self.peek_digitrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek_digit().(i).is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 354 | i 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().1; |
| 355 | } |
| 356 | // INVARIANT: Skipping `i` digits is fine. |
| 357 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(i); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | fn read_ip_literalrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_ip_literal().(&mut self) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#>> { |
| 362 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().("[") { |
| 363 | 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#); |
| 364 | } |
| 365 | |
| 366 | let start = self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.; |
| 367 | |
| 368 | let meta = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_addr) = self.read_v6rust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v6().() { |
| 369 | HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#::Ipv6rust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#Ipv6#( |
| 370 | #[cfg(feature = "net")] |
| 371 | _addr.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 372 | ) |
| 373 | } else if self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().start { |
| 374 | self.read_ipv_futurerust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_ipv_future().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 375 | HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#::IpvFuturerust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#IpvFuture# |
| 376 | } else { |
| 377 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(start, InvalidIpv6Addrrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#InvalidIpv6Addr#); |
| 378 | }; |
| 379 | |
| 380 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().("]") { |
| 381 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#); |
| 382 | } |
| 383 | 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#(meta)) |
| 384 | } |
| 385 | |
| 386 | fn read_ipv_futurerust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_ipv_future().(&mut self) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<()> { |
| 387 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'v' | b'V') = self.peekrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek().(0) { |
| 388 | // INVARIANT: Skipping "v" or "V" is fine. |
| 389 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(1); |
| 390 | if self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(HEXDIGrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/HEXDIG.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). && self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().(".") && self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(IPV_FUTURErust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/IPV_FUTURE.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 391 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 392 | } |
| 393 | } |
| 394 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) fn parse_v4_or_reg_namerust-analyzer cargo fluent-uri 0.4.1 parse/parse_v4_or_reg_name().(bytes: &[u8]) -> HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta# { |
| 399 | let mut reader = Readerrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#::newrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]new().(bytes); |
| 400 | match reader.read_v4rust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v4().() { |
| 401 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_addr) if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().reader.has_remainingrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]has_remaining().() => HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#::Ipv4rust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#Ipv4#( |
| 402 | #[cfg(feature = "net")] |
| 403 | _addr.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 404 | ), |
| 405 | _ => HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#::RegNamerust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#RegName#, |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | #[cfg(all(feature = "alloc", not(feature = "net")))] |
| 410 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) fn parse_v6(bytes: &[u8]) -> [u16; 8] { |
| 411 | Readerrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#::new(bytes).read_v6().unwrap() |
| 412 | } |
| 413 | |
| 414 | impl Parserrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#<'_> { |
| 415 | fn selectrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]select().<T>(&self, for_uri: T, for_iri: T) -> T { |
| 416 | if self.constraintsrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#constraints..ascii_onlyrust-analyzer cargo fluent-uri 0.4.1 imp/Constraints#ascii_only. { |
| 417 | for_uri |
| 418 | } else { |
| 419 | for_iri |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | fn read_v4_or_reg_namerust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]read_v4_or_reg_name().(&mut self) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#> { |
| 424 | let reg_name_table = self.selectrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]select().(REG_NAMErust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/REG_NAME., IREG_NAMErust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/IREG_NAME.); |
| 425 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match (self.read_v4rust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_v4().(), self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(reg_name_table)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) { |
| 426 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_addr), false) => HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#::Ipv4rust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#Ipv4#( |
| 427 | #[cfg(feature = "net")] |
| 428 | _addr.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 429 | ), |
| 430 | _ => HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#::RegNamerust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#RegName#, |
| 431 | }) |
| 432 | } |
| 433 | |
| 434 | fn read_hostrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]read_host().(&mut self) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#> { |
| 435 | match self.read_ip_literalrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_ip_literal().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 436 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(host) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(host), |
| 437 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.read_v4_or_reg_namerust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]read_v4_or_reg_name().(), |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | fn parse_from_schemerust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]parse_from_scheme().(&mut self) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<()> { |
| 442 | self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(SCHEMErust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/SCHEME.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 443 | |
| 444 | if self.peekrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek().(0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b':') { |
| 445 | // Scheme starts with a letter. |
| 446 | if self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 && self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes.[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()..is_ascii_alphabeticrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii_alphabetic().() { |
| 447 | self.outrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#out..scheme_endrust-analyzer cargo fluent-uri 0.4.1 imp/Meta#scheme_end. = NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.); |
| 448 | } else { |
| 449 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(0, UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#); |
| 450 | } |
| 451 | |
| 452 | // INVARIANT: Skipping ":" is fine. |
| 453 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(1); |
| 454 | return if self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().("//") { |
| 455 | self.parse_from_authorityrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]parse_from_authority().() |
| 456 | } else { |
| 457 | self.parse_from_pathrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]parse_from_path().(PathKindrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#::Generalrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#General#) |
| 458 | }; |
| 459 | } else if self.constraintsrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#constraints..scheme_requiredrust-analyzer cargo fluent-uri 0.4.1 imp/Constraints#scheme_required. { |
| 460 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#); |
| 461 | } else if self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 462 | // Nothing read. |
| 463 | if self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().("//") { |
| 464 | return self.parse_from_authorityrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]parse_from_authority().(); |
| 465 | } |
| 466 | } |
| 467 | // Scheme chars are valid for path. |
| 468 | self.parse_from_pathrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]parse_from_path().(PathKindrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#::ContinuedNoSchemerust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#ContinuedNoScheme#) |
| 469 | } |
| 470 | |
| 471 | fn parse_from_authorityrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]parse_from_authority().(&mut self) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<()> { |
| 472 | let host; |
| 473 | |
| 474 | let mut colon_cnt = 0; |
| 475 | let mut colon_i = 0; |
| 476 | |
| 477 | let auth_start = self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.; |
| 478 | |
| 479 | let userinfo_table = self.selectrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]select().(USERINFOrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/USERINFO., IUSERINFOrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/IUSERINFO.); |
| 480 | // `userinfo_table` contains userinfo, registered name, ':', and port. |
| 481 | self._readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]_read().(userinfo_table, |i, x| { |
| 482 | if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().':' as u32 { |
| 483 | colon_cnt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1; |
| 484 | colon_i = i; |
| 485 | } |
| 486 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 487 | |
| 488 | if self.peekrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek().(0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b'@') { |
| 489 | // Userinfo present. |
| 490 | // INVARIANT: Skipping "@" is fine. |
| 491 | self.skiprust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]skip().(1); |
| 492 | |
| 493 | let host_start = self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.; |
| 494 | let meta = self.read_hostrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]read_host().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 495 | host = (host_start, self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., meta); |
| 496 | |
| 497 | self.read_portrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_port().(); |
| 498 | } else if self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().auth_start { |
| 499 | // Nothing read. We're now at the start of an IP literal or the path. |
| 500 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(meta) = self.read_ip_literalrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_ip_literal().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 501 | host = (auth_start, self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., meta); |
| 502 | self.read_portrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_port().(); |
| 503 | } else { |
| 504 | // Empty authority. |
| 505 | host = (self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#::RegNamerust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#RegName#); |
| 506 | } |
| 507 | } else { |
| 508 | // The whole authority read. Try to parse the host and port. |
| 509 | let host_end = match colon_cnt { |
| 510 | // All host. |
| 511 | 0 => self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., |
| 512 | // Host and port. |
| 513 | 1 => { |
| 514 | for i in colon_i 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#self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos. { |
| 515 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..is_ascii_digitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii_digit().() { |
| 516 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(i, UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#); |
| 517 | } |
| 518 | } |
| 519 | colon_i |
| 520 | } |
| 521 | // Multiple colons. |
| 522 | _ => errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(colon_i, UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#), |
| 523 | }; |
| 524 | |
| 525 | let meta = parse_v4_or_reg_namerust-analyzer cargo fluent-uri 0.4.1 parse/parse_v4_or_reg_name().(&self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().auth_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#host_end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 526 | host = (auth_start, host_end, meta); |
| 527 | } |
| 528 | |
| 529 | self.outrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#out..auth_metarust-analyzer cargo fluent-uri 0.4.1 imp/Meta#auth_meta. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AuthMetarust-analyzer cargo fluent-uri 0.4.1 imp/AuthMeta# { |
| 530 | host_boundsrust-analyzer cargo fluent-uri 0.4.1 imp/AuthMeta#host_bounds.: (host.0, host.1), |
| 531 | host_metarust-analyzer cargo fluent-uri 0.4.1 imp/AuthMeta#host_meta.: host.2, |
| 532 | }); |
| 533 | self.parse_from_pathrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]parse_from_path().(PathKindrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#::AbEmptyrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#AbEmpty#) |
| 534 | } |
| 535 | |
| 536 | fn parse_from_pathrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]parse_from_path().(&mut self, kind: PathKindrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#) -> Resultrust-analyzer cargo fluent-uri 0.4.1 parse/Result#<()> { |
| 537 | let path_table = self.selectrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]select().(PATHrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/PATH., IPATHrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/IPATH.); |
| 538 | self.outrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#out..path_boundsrust-analyzer cargo fluent-uri 0.4.1 imp/Meta#path_bounds. = match kind { |
| 539 | PathKindrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#::Generalrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#General# => { |
| 540 | let start = self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.; |
| 541 | self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(path_table)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 542 | (start, self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.) |
| 543 | } |
| 544 | PathKindrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#::AbEmptyrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#AbEmpty# => { |
| 545 | let start = self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.; |
| 546 | // Either empty or starting with '/'. |
| 547 | if self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(path_table)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). && self.bytesrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#bytes.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().start]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 cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b'/' { |
| 548 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(start, UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#); |
| 549 | } |
| 550 | (start, self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.) |
| 551 | } |
| 552 | PathKindrust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#::ContinuedNoSchemerust-analyzer cargo fluent-uri 0.4.1 parse/PathKind#ContinuedNoScheme# => { |
| 553 | let segment_table = self.selectrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]select().(SEGMENT_NZ_NCrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/SEGMENT_NZ_NC., ISEGMENT_NZ_NCrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/ISEGMENT_NZ_NC.); |
| 554 | self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(segment_table)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 555 | |
| 556 | if self.peekrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]peek().(0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(b':') { |
| 557 | // In a relative reference, the first path |
| 558 | // segment cannot contain a colon character. |
| 559 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#); |
| 560 | } |
| 561 | |
| 562 | self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(path_table)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 563 | (0, self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.) |
| 564 | } |
| 565 | }; |
| 566 | |
| 567 | if self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().("?") { |
| 568 | let query_table = self.selectrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]select().(QUERYrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/QUERY., IQUERYrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/IQUERY.); |
| 569 | self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(query_table)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 570 | self.outrust-analyzer cargo fluent-uri 0.4.1 parse/Parser#out..query_endrust-analyzer cargo fluent-uri 0.4.1 imp/Meta#query_end. = NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos.); |
| 571 | } |
| 572 | |
| 573 | if self.read_strrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read_str().("#") { |
| 574 | let fragment_table = self.selectrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Parser<'_>`]select().(FRAGMENTrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/FRAGMENT., IFRAGMENTrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/IFRAGMENT.); |
| 575 | self.readrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]read().(fragment_table)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 576 | } |
| 577 | |
| 578 | if self.has_remainingrust-analyzer cargo fluent-uri 0.4.1 parse/impl#[`Reader<'a>`]has_remaining().() { |
| 579 | errrust-analyzer cargo fluent-uri 0.4.1 parse/err!!(self.posrust-analyzer cargo fluent-uri 0.4.1 parse/Reader#pos., UnexpectedCharrust-analyzer cargo fluent-uri 0.4.1 parse/ParseErrorKind#UnexpectedChar#); |
| 580 | } |
| 581 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 582 | } |
| 583 | } |