uniresid/context.rs
1/// This enumerates the various places where an error might occur parsing a
2/// URI.
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum Context {
5 /// This is the fragment of the URI, such as `#baz` in
6 /// `http://www.example.com/foo?bar#baz`.
7 Fragment,
8
9 /// This is the host name of the URI, such as `www.example.com` in
10 /// `http://www.example.com/foo?bar#baz`.
11 Host,
12
13 /// This is the IPv4 portion of the IPv6 host name in the URI, such as
14 /// `1.2.3.4` in `http://[::ffff:1.2.3.4]/foo?bar#baz`.
15 Ipv4Address,
16
17 /// This is the IPv6 host name in the URI, such as
18 /// `::ffff:1.2.3.4` in `http://[::ffff:1.2.3.4]/foo?bar#baz`.
19 Ipv6Address,
20
21 /// This is the `IPvFuture` host name in the URI, such as
22 /// `v7.aB` in `http://[v7.aB]/foo?bar#baz`.
23 IpvFuture,
24
25 /// This is the path of the URI, such as `/foo` in
26 /// `http://www.example.com/foo?bar#baz`.
27 Path,
28
29 /// This is the query of the URI, such as `?bar` in
30 /// `http://www.example.com/foo?bar#baz`.
31 Query,
32
33 /// This is the scheme of the URI, such as `http` in
34 /// `http://www.example.com/foo?bar#baz`.
35 Scheme,
36
37 /// This is the scheme of the URI, such as `nobody` in
38 /// `http://nobody@www.example.com/foo?bar#baz`.
39 UserInfo,
40}
41
42impl std::fmt::Display for Context {
43 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44 match self {
45 Context::Fragment => write!(f, "fragment"),
46 Context::Host => write!(f, "host"),
47 Context::Ipv4Address => write!(f, "IPv4 address"),
48 Context::Ipv6Address => write!(f, "IPv6 address"),
49 Context::IpvFuture => write!(f, "IPvFuture"),
50 Context::Path => write!(f, "path"),
51 Context::Query => write!(f, "query"),
52 Context::Scheme => write!(f, "scheme"),
53 Context::UserInfo => write!(f, "user info"),
54 }
55 }
56}