pub struct CountryCode {
pub(crate) inner: [NonZeroU8; 2],
}
Expand description
A two-letter country code.
Specifically, this type represents a purported “ISO 3166-1 alpha-2” country code, such as “IT” for Italy or “UY” for Uruguay.
It does not include the sentinel value ??
that we use to represent
“country unknown”; if you need that, use OptionCc
. Other than that, we
do not check whether the country code represents a real country: we only
ensure that it is a pair of printing ASCII characters.
Note that the geoip databases included with Arti will only include real
countries; we do not include the pseudo-countries A1
through An
for
“anonymous proxies”, since doing so would mean putting nearly all Tor relays
into one of those countries.
Fields§
§inner: [NonZeroU8; 2]
The underlying value (two printable ASCII characters, stored uppercase).
The special value ??
is excluded, since it is not a country; use
OptionCc
instead if you need to represent that.
We store these as NonZeroU8
so that an Option<CountryCode>
only has to
take 2 bytes. This helps with alignment and storage.
Implementations§
Trait Implementations§
Source§impl AsRef<str> for CountryCode
impl AsRef<str> for CountryCode
Source§impl Clone for CountryCode
impl Clone for CountryCode
Source§fn clone(&self) -> CountryCode
fn clone(&self) -> CountryCode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more