1use crate::internal::NoInput;
4
5#[derive(Clone, Copy, Debug)]
7pub(crate) enum ParseErrorKind {
8 InvalidOctet,
12 UnexpectedChar,
16 InvalidIpv6Addr,
20 NoScheme,
22}
23
24#[derive(Clone, Copy)]
26pub struct ParseError<I = NoInput> {
27 pub(crate) index: usize,
28 pub(crate) kind: ParseErrorKind,
29 pub(crate) input: I,
30}
31
32impl ParseError {
33 pub(crate) fn with_input<I>(self, input: I) -> ParseError<I> {
34 ParseError {
35 index: self.index,
36 kind: self.kind,
37 input,
38 }
39 }
40}
41
42impl<I: AsRef<str>> ParseError<I> {
43 #[must_use]
45 pub fn into_input(self) -> I {
46 self.input
47 }
48
49 #[must_use]
51 pub fn strip_input(&self) -> ParseError {
52 ParseError {
53 index: self.index,
54 kind: self.kind,
55 input: NoInput,
56 }
57 }
58}
59
60#[cfg(feature = "std")]
61impl<I> std::error::Error for ParseError<I> {}
62
63#[derive(Clone, Copy, Debug)]
65pub(crate) enum BuildErrorKind {
66 NonAbemptyPath,
67 PathStartingWithDoubleSlash,
68 ColonInFirstPathSegment,
69}
70
71#[derive(Clone, Copy, Debug)]
73pub struct BuildError(pub(crate) BuildErrorKind);
74
75#[cfg(feature = "std")]
76impl std::error::Error for BuildError {}
77
78#[derive(Clone, Copy, Debug)]
80pub(crate) enum ResolveErrorKind {
81 InvalidBase,
82 OpaqueBase,
83 }
85
86#[derive(Clone, Copy, Debug)]
88pub struct ResolveError(pub(crate) ResolveErrorKind);
89
90#[cfg(feature = "std")]
91impl std::error::Error for ResolveError {}