Struct phonenumber::metadata::Descriptor

source ·
pub struct Descriptor { /* private fields */ }
Expand description

Description of a phone number to parse.

Implementations§

source§

impl Descriptor

source

pub fn national_number(&self) -> &CachedRegex

The national number is the pattern that a valid national significant number would match. This specifies information such as its total length and leading digits.

source

pub fn possible_length(&self) -> &[u16]

These represent the lengths a phone number from this region can be. They will be sorted from smallest to biggest. Note that these lengths are for the full number, without country calling code or national prefix. For example, for the Swiss number +41789270000, in local format 0789270000, this would be 9.

This could be used to highlight tokens in a text that may be a phone number, or to quickly prune numbers that could not possibly be a phone number for this locale.

source

pub fn possible_local_length(&self) -> &[u16]

These represent the lengths that only local phone numbers (without an area code) from this region can be. They will be sorted from smallest to biggest. For example, since the American number 456-1234 may be locally diallable, although not diallable from outside the area, 7 could be a possible value. This could be used to highlight tokens in a text that may be a phone number.

To our knowledge, area codes are usually only relevant for some fixed-line and mobile numbers, so this field should only be set for those types of numbers (and the general description) - however there are exceptions for NANPA countries.

This data is used to calculate whether a number could be a possible number for a particular type.

source

pub fn example(&self) -> Option<&str>

An example national significant number for the specific type. It should not contain any formatting information.

source

pub fn is_match(&self, value: &str) -> bool

Check if the descriptor matches the given national number.

Trait Implementations§

source§

impl Clone for Descriptor

source§

fn clone(&self) -> Descriptor

Returns a copy 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 Debug for Descriptor

source§

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

Formats the value using the given formatter. Read more

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> 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,

§

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>,

§

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>,

§

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.