1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
use ;
/// High-level IP classification used by IP Flag.
///
/// This classification is intentionally simple and UI-oriented:
/// - `Private`: local network / internal addresses (LAN), never resolved
/// - `Special`: loopback/multicast/documentation/unspecified/broadcast, never resolved
/// - `Public`: eligible for resolution via [`crate::IpResolver`]
///
/// Note: Different applications may want deeper classification. IP Flag keeps this minimal.
/// Parse a string into [`IpAddr`].
///
/// This is a small helper around `str::parse::<IpAddr>()`.
///
/// # Example
///
/// ```rust
/// use ipflag::parse_ip;
///
/// assert!(parse_ip("8.8.8.8").is_ok());
/// assert!(parse_ip("not-an-ip").is_err());
/// ```
/// Classify an [`IpAddr`] into [`IpScope`].
///
/// IP Flag will only call user resolvers for `Public` addresses.
///
/// # Example
///
/// ```rust
/// use ipflag::{classify_ip, parse_ip, IpScope};
///
/// let ip = parse_ip("192.168.0.1").unwrap();
/// assert_eq!(classify_ip(ip), IpScope::Private);
/// ```
/// Classify an IPv4 address into [`IpScope`].
///
/// This function is public so that downstream crates can reuse
/// IP Flag's exact IPv4 classification logic without reimplementing it.
///
/// Classification rules:
/// - Private: RFC1918 + link-local ranges
/// - Special: loopback, multicast, documentation, unspecified, broadcast
/// - Public: everything else
///
/// This function never performs resolution by itself.
/// Classify an IPv6 address into [`IpScope`].
///
/// This mirrors the behavior of [`classify_v4`] but for IPv6:
/// - Private: unique-local (fc00::/7) and unicast link-local (fe80::/10)
/// - Special: loopback, multicast, unspecified
/// - Public: all other global unicast addresses
///
/// This function is public to allow reuse by custom resolvers
/// or higher-level network tooling.