#[repr(transparent)]pub struct CountryCode {
pub(crate) inner: NonZeroU16,
}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: NonZeroU16The 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 NonZeroU16 so that an Option<CountryCode> only has to
take 2 bytes. This helps with alignment and storage.
(We use a NonZeroU16 rather than [NonZeroU8; 2] to ensure that every
bit representation is a valid Option<CountryCode>.)
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CountryCode
impl Debug for CountryCode
Source§impl Display for CountryCode
impl Display for CountryCode
Source§impl FromStr for CountryCode
impl FromStr for CountryCode
Source§impl PartialEq for CountryCode
impl PartialEq for CountryCode
Source§fn eq(&self, other: &CountryCode) -> bool
fn eq(&self, other: &CountryCode) -> bool
self and other values to be equal, and is used by ==.