Skip to main content

PhoneMetadata

Struct PhoneMetadata 

Source
pub struct PhoneMetadata {
Show 31 fields pub general_desc: Option<PhoneNumberDesc>, pub fixed_line: Option<PhoneNumberDesc>, pub mobile: Option<PhoneNumberDesc>, pub toll_free: Option<PhoneNumberDesc>, pub premium_rate: Option<PhoneNumberDesc>, pub shared_cost: Option<PhoneNumberDesc>, pub personal_number: Option<PhoneNumberDesc>, pub voip: Option<PhoneNumberDesc>, pub pager: Option<PhoneNumberDesc>, pub uan: Option<PhoneNumberDesc>, pub emergency: Option<PhoneNumberDesc>, pub voicemail: Option<PhoneNumberDesc>, pub short_code: Option<PhoneNumberDesc>, pub standard_rate: Option<PhoneNumberDesc>, pub carrier_specific: Option<PhoneNumberDesc>, pub sms_services: Option<PhoneNumberDesc>, pub no_international_dialling: Option<PhoneNumberDesc>, pub id: String, pub country_code: Option<i32>, pub international_prefix: Option<String>, pub preferred_international_prefix: Option<String>, pub national_prefix: Option<String>, pub preferred_extn_prefix: Option<String>, pub national_prefix_for_parsing: Option<String>, pub national_prefix_transform_rule: Option<String>, pub same_mobile_and_fixed_line_pattern: Option<bool>, pub number_format: Vec<NumberFormat>, pub intl_number_format: Vec<NumberFormat>, pub main_country_for_code: Option<bool>, pub leading_digits: Option<String>, pub mobile_number_portable_region: Option<bool>,
}
Expand description

If you add, remove, or rename fields, or change their semantics, check if you should change the excludable field sets or the behavior in MetadataFilter.

Fields§

§general_desc: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

The general_desc contains information which is a superset of descriptions for all types of phone numbers. If any element is missing in the description of a specific type in the XML file, the element will inherit from its counterpart in the general_desc. For all types that are generally relevant to normal phone numbers, if the whole type is missing in the PhoneNumberMetadata XML file, it will not have national number data, and the possible lengths will be [-1].

§fixed_line: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§mobile: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§toll_free: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§premium_rate: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§shared_cost: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§personal_number: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§voip: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§pager: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§uan: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§emergency: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§voicemail: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§short_code: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§standard_rate: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§carrier_specific: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§sms_services: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

§no_international_dialling: Option<PhoneNumberDesc>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

The rules here distinguish the numbers that are only able to be dialled nationally.

§id: String

The CLDR 2-letter representation of a country/region, with the exception of “country calling codes” used for non-geographical entities, such as Universal International Toll Free Number (+800). These are all given the ID “001”, since this is the numeric region code for the world according to UN M.49: http://en.wikipedia.org/wiki/UN_M.49

§country_code: Option<i32>

The country calling code that one would dial from overseas when trying to dial a phone number in this country. For example, this would be “64” for New Zealand.

§international_prefix: Option<String>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

The international_prefix of country A is the number that needs to be dialled from country A to another country (country B). This is followed by the country code for country B. Note that some countries may have more than one international prefix, and for those cases, a regular expression matching the international prefixes will be stored in this field.

§preferred_international_prefix: Option<String>

If the international prefix that we want to use when formatting the number for out-of-country dialling contains non-digit symbols, or there is more than one international prefix is present, a preferred prefix can be specified here for out-of-country formatting purposes. If this field is not present, and multiple international prefixes are present, then “+” will be used instead.

§national_prefix: Option<String>

The national prefix of country A is the number that needs to be dialled before the national significant number when dialling internally. This would not be dialled when dialling internationally. For example, in New Zealand, the number that would be locally dialled as 09 345 3456 would be dialled from overseas as +64 9 345 3456. In this case, 0 is the national prefix.

§preferred_extn_prefix: Option<String>

The preferred prefix when specifying an extension in this country. This is used for formatting only, and if this is not specified, a suitable default should be used instead. For example, if you wanted extensions to be formatted in the following way: 1 (365) 345 445 ext. 2345 “ ext. “ should be the preferred extension prefix.

§national_prefix_for_parsing: Option<String>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

This field is used for cases where the national prefix of a country contains a carrier selection code, and is written in the form of a regular expression. For example, to dial the number 2222-2222 in Fortaleza, Brazil (area code 85) using the long distance carrier Oi (selection code 31), one would dial 0 31 85 2222 2222. Assuming the only other possible carrier selection code is 32, the field will contain “03[12]”.

When it is missing from the XML file, this field inherits the value of national_prefix, if that is present.

§national_prefix_transform_rule: Option<String>

This field is only populated and used under very rare situations. For example, mobile numbers in Argentina are written in two completely different ways when dialed in-country and out-of-country (e.g. 0343 15 555 1212 is exactly the same number as +54 9 343 555 1212). This field is used together with national_prefix_for_parsing to transform the number into a particular representation for storing in the phonenumber proto buffer in those rare cases.

§same_mobile_and_fixed_line_pattern: Option<bool>

Specifies whether the mobile and fixed-line patterns are the same or not. This is used to speed up determining phone number type in countries where these two types of phone numbers can never be distinguished.

§number_format: Vec<NumberFormat>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

Note that the number format here is used for formatting only, not parsing. Hence all the varied ways a user may write a number need not be recorded

  • just the ideal way we would like to format it for them. When this element is absent, the national significant number will be formatted as a whole without any formatting applied.
§intl_number_format: Vec<NumberFormat>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

This field is populated only when the national significant number is formatted differently when it forms part of the INTERNATIONAL format and NATIONAL format. A case in point is mobile numbers in Argentina: The number, which would be written in INTERNATIONAL format as +54 9 343 555 1212, will be written as 0343 15 555 1212 for NATIONAL format. In this case, the prefix 9 is inserted when dialling from overseas, but otherwise the prefix 0 and the carrier selection code 15 (inserted after the area code of 343) is used. Note: this field is populated by setting a value for inside the tag in the XML file. If is not set then it defaults to the same value as the tag.

Examples: To set the to a different value than the : $1 $2 $3 $1-$2-$3

To have a format only used for national formatting, set to “NA”: $1 $2 $3 NA

§main_country_for_code: Option<bool>

This field is set when this country is considered to be the main country for a calling code. It may not be set by more than one country with the same calling code, and it should not be set by countries with a unique calling code. This can be used to indicate that “GB” is the main country for the calling code “44” for example, rather than Jersey or the Isle of Man.

§leading_digits: Option<String>
👎Deprecated:

This field is shadowed by the wrapper and is intentionally left empty. Access the underlying data via .original.

This field is populated only for countries or regions that share a country calling code. If a number matches this pattern, it could belong to this region. This is not intended as a replacement for IsValidForRegion since a matching prefix is insufficient for a number to be valid. Furthermore, it does not contain all the prefixes valid for a region - for example, 800 numbers are valid for all NANPA countries and are hence not listed here. This field should be a regular expression of the expected prefix match. It is used merely as a short-cut for working out which region a number comes from in the case that there is only one, so leading_digit prefixes should not overlap.

§mobile_number_portable_region: Option<bool>

This field is set when this country has implemented mobile number portability. This means that transferring mobile numbers between carriers is allowed. A consequence of this is that phone prefix to carrier mapping is less reliable.

Implementations§

Source§

impl PhoneMetadata

Source

pub fn country_code(&self) -> i32

Returns the value of country_code, or the default value if country_code is unset.

Source

pub fn international_prefix(&self) -> &str

Returns the value of international_prefix, or the default value if international_prefix is unset.

Source

pub fn national_prefix(&self) -> &str

Returns the value of national_prefix, or the default value if national_prefix is unset.

Source

pub fn preferred_extn_prefix(&self) -> &str

Returns the value of preferred_extn_prefix, or the default value if preferred_extn_prefix is unset.

Source

pub fn national_prefix_for_parsing(&self) -> &str

Returns the value of national_prefix_for_parsing, or the default value if national_prefix_for_parsing is unset.

Source

pub fn national_prefix_transform_rule(&self) -> &str

Returns the value of national_prefix_transform_rule, or the default value if national_prefix_transform_rule is unset.

Source

pub fn preferred_international_prefix(&self) -> &str

Returns the value of preferred_international_prefix, or the default value if preferred_international_prefix is unset.

Source

pub fn same_mobile_and_fixed_line_pattern(&self) -> bool

Returns the value of same_mobile_and_fixed_line_pattern, or the default value if same_mobile_and_fixed_line_pattern is unset.

Source

pub fn main_country_for_code(&self) -> bool

Returns the value of main_country_for_code, or the default value if main_country_for_code is unset.

Source

pub fn leading_digits(&self) -> &str

Returns the value of leading_digits, or the default value if leading_digits is unset.

Source

pub fn mobile_number_portable_region(&self) -> bool

Returns the value of mobile_number_portable_region, or the default value if mobile_number_portable_region is unset.

Trait Implementations§

Source§

impl Clone for PhoneMetadata

Source§

fn clone(&self) -> PhoneMetadata

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PhoneMetadata

Source§

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

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

impl Default for PhoneMetadata

Source§

fn default() -> Self

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

impl Message for PhoneMetadata

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for PhoneMetadata

Source§

fn eq(&self, other: &PhoneMetadata) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for PhoneMetadata

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.