#[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
impl Copy for CountryCode
Source§impl Debug for CountryCode
impl Debug for CountryCode
Source§impl<'de> Deserialize<'de> for CountryCode
impl<'de> Deserialize<'de> for CountryCode
Source§fn deserialize<__D>(deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for CountryCode
impl Display for CountryCode
impl Eq for CountryCode
Source§impl FromStr for CountryCode
impl FromStr for CountryCode
Source§impl PartialEq for CountryCode
impl PartialEq for CountryCode
Source§impl Serialize for CountryCodewhere
Self: Display,
impl Serialize for CountryCodewhere
Self: Display,
impl StructuralPartialEq for CountryCode
Auto Trait Implementations§
impl Forget for CountryCode
impl Freeze for CountryCode
impl Move for CountryCode
impl RefUnwindSafe for CountryCode
impl Send for CountryCode
impl Sync for CountryCode
impl Unpin for CountryCode
impl UnsafeUnpin for CountryCode
impl UnwindSafe for CountryCode
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more