Names

Struct Names 

Source
pub struct Names<'a> {
    pub german: Option<&'a str>,
    pub english: Option<&'a str>,
    pub spanish: Option<&'a str>,
    pub french: Option<&'a str>,
    pub japanese: Option<&'a str>,
    pub brazilian_portuguese: Option<&'a str>,
    pub russian: Option<&'a str>,
    pub simplified_chinese: Option<&'a str>,
}
Expand description

Localized names for geographic entities.

Contains name translations in the languages supported by MaxMind databases. Access names directly via fields like names.english or names.german. Each field is Option<&str> - None if not available in that language.

§Example

use maxminddb::{Reader, geoip2};
use std::net::IpAddr;

let reader = Reader::open_readfile("test-data/test-data/GeoIP2-City-Test.mmdb").unwrap();
let ip: IpAddr = "89.160.20.128".parse().unwrap();
let result = reader.lookup(ip).unwrap();

if let Some(city) = result.decode::<geoip2::City>().unwrap() {
    // Access names directly - Option<&str>
    if let Some(name) = city.city.names.english {
        println!("City (en): {}", name);
    }
    if let Some(name) = city.city.names.german {
        println!("City (de): {}", name);
    }
}

Fields§

§german: Option<&'a str>

German name (de)

§english: Option<&'a str>

English name (en)

§spanish: Option<&'a str>

Spanish name (es)

§french: Option<&'a str>

French name (fr)

§japanese: Option<&'a str>

Japanese name (ja)

§brazilian_portuguese: Option<&'a str>

Brazilian Portuguese name (pt-BR)

§russian: Option<&'a str>

Russian name (ru)

§simplified_chinese: Option<&'a str>

Simplified Chinese name (zh-CN)

Implementations§

Source§

impl Names<'_>

Source

pub fn is_empty(&self) -> bool

Returns true if all name fields are None.

Trait Implementations§

Source§

impl<'a> Clone for Names<'a>

Source§

fn clone(&self) -> Names<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Names<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Names<'a>

Source§

fn default() -> Names<'a>

Returns the “default value” for a type. Read more
Source§

impl<'de: 'a, 'a> Deserialize<'de> for Names<'a>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> PartialEq for Names<'a>

Source§

fn eq(&self, other: &Names<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Serialize for Names<'a>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> Eq for Names<'a>

Source§

impl<'a> StructuralPartialEq for Names<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Names<'a>

§

impl<'a> RefUnwindSafe for Names<'a>

§

impl<'a> Send for Names<'a>

§

impl<'a> Sync for Names<'a>

§

impl<'a> Unpin for Names<'a>

§

impl<'a> UnwindSafe for Names<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,