pub struct GeoCatalog {
pub regions: Vec<GeoRegion>,
pub subregions: Vec<GeoSubregion>,
pub countries: Vec<GeoCountry>,
}Expand description
The regions, sub-regions and countries a geo ban can name (ISO 3166-1 + UN M49), as
Core serves them from Relay’s country table (GET /api/v1/geo). A geo ban code is
valid only if it is in here at its level.
Read it with Geo::catalog; name lookups are methods
(GeoCatalog::parse_area, GeoCatalog::name, GeoCatalog::known_areas).
Core lets clients cache it for a day; serializable, so a caller can keep a copy.
Fields§
§regions: Vec<GeoRegion>Continent-sized UN M49 regions (Europe, 150).
subregions: Vec<GeoSubregion>UN M49 sub-regions (Southern Europe, 39).
countries: Vec<GeoCountry>Countries and territories (Croatia, 191).
Implementations§
Source§impl GeoCatalog
impl GeoCatalog
Sourcepub fn parse_area(&self, input: &str) -> Result<GeoArea>
pub fn parse_area(&self, input: &str) -> Result<GeoArea>
Resolves what a user typed. Accepted, case-insensitive: level:code or
level:name (country:276, region:Europe), a country alpha-2 or alpha-3 code
(DE, DEU), a country, region or sub-region name. A bare number is ambiguous
(region and country codes overlap) and needs a level prefix.
§Errors
Error::InvalidInput for an unknown or ambiguous area, or a code that is not in
the catalog at its level (Core would refuse it); the message says what is accepted.
GeoCatalog::known_areas lists every area.
§Examples
use dinio_sdk::models::GeoCatalog;
use dinio_sdk::ops::GeoLevel;
// let catalog = client.geo().catalog().await?;
let hr = catalog.parse_area("HR")?;
assert_eq!((hr.level, hr.code), (GeoLevel::Country, 191));
assert_eq!(catalog.parse_area("croatia")?, hr);
assert_eq!(catalog.parse_area("Europe")?.level, GeoLevel::Region);
assert!(catalog.parse_area("150").is_err()); // region or country? say `region:150`
assert!(catalog.parse_area("country:999").is_err()); // not in the catalogSourcepub fn name(&self, area: GeoArea) -> Option<&str>
pub fn name(&self, area: GeoArea) -> Option<&str>
The area’s English name (Germany, Europe), if the catalog has it.
Sourcepub fn describe(&self, area: GeoArea) -> String
pub fn describe(&self, area: GeoArea) -> String
Country Germany (276); an area the catalog does not have shows without a name
(Country 999).
Sourcepub fn known_areas(&self) -> Vec<KnownArea<'_>>
pub fn known_areas(&self) -> Vec<KnownArea<'_>>
Every area: regions, then sub-regions, then countries.
Trait Implementations§
Source§impl Clone for GeoCatalog
impl Clone for GeoCatalog
Source§fn clone(&self) -> GeoCatalog
fn clone(&self) -> GeoCatalog
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 GeoCatalog
impl Debug for GeoCatalog
Source§impl<'de> Deserialize<'de> for GeoCatalog
impl<'de> Deserialize<'de> for GeoCatalog
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>,
impl Eq for GeoCatalog
Source§impl PartialEq for GeoCatalog
impl PartialEq for GeoCatalog
Source§impl Serialize for GeoCatalog
impl Serialize for GeoCatalog
impl StructuralPartialEq for GeoCatalog
Auto Trait Implementations§
impl Freeze for GeoCatalog
impl RefUnwindSafe for GeoCatalog
impl Send for GeoCatalog
impl Sync for GeoCatalog
impl Unpin for GeoCatalog
impl UnsafeUnpin for GeoCatalog
impl UnwindSafe for GeoCatalog
Blanket Implementations§
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
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>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.