pub struct PhoneNumber(/* private fields */);Expand description
O’zbekiston telefon raqami — ichkarida har doim 998 + 9 raqam (12 raqam, + siz).
parse() strukturani tekshiradi va formatga toqatli:
+998 (90) 123-45-67, 998.90.123.45.67, +998901234567 — hammasi 998901234567.
Tashlab yuboriladigan ajratuvchilar: bo’shliq, -, (, ), . va boshidagi +.
Operator/hudud kodi ro’yxati — o’zgaruvchan biznes fakti — parse ichida emas:
PhoneNumber::is_known_operator, PhoneNumber::is_mobile yoki PhoneNumber::parse_strict.
Implementations§
Source§impl PhoneNumber
impl PhoneNumber
Sourcepub fn parse(value: &str) -> Result<Self, PhoneNumberError>
pub fn parse(value: &str) -> Result<Self, PhoneNumberError>
Matndan tip yaratadi: trim → normalizatsiya → validatsiya.
Bitta allocation (normalizatsiya qilingan nusxa uchun).
Sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Ichki String (ownership ko’chadi, nusxa olinmaydi).
Source§impl PhoneNumber
impl PhoneNumber
Sourcepub const COUNTRY_CODE: &str = "998"
pub const COUNTRY_CODE: &str = "998"
Davlat kodi.
Sourcepub const OPERATOR_CODE_LEN: usize = 2
pub const OPERATOR_CODE_LEN: usize = 2
Operator/hudud kodi uzunligi.
Sourcepub const MOBILE_CODES: &[&str]
pub const MOBILE_CODES: &[&str]
Ma’lum mobil kodlar. Slice — yangi kod qo’shish breaking emas.
Boshlang’ich reja: ITU’ning 2023-02-10 dagi E.164 yangilanishi. Keyingi manbalar: 20 (2026-09-07 da tekshirildi), 70 (2025-03-19), 80 (2026-09-07 da tekshirildi), 87 (2026-04-16) va 92 (7-noyabr; 2026-09-07 da tekshirildi).
70 kodi mobil va geografik xizmatlarda ishlatiladi, shuning uchun tasniflar
o’zaro istisno emas. Registry vaqt o’tishi bilan eskirishi mumkin;
parse undan foydalanmaydi.
Sourcepub const GEOGRAPHIC_CODES: &[&str]
pub const GEOGRAPHIC_CODES: &[&str]
Geografik PSTN kodlari.
Manba: ITU’ning 2023-02-10 dagi
O’zbekiston E.164 rejasi.
70 keyinchalik mobil xizmatga ham ajratilgan; shu sabab u ikki to’plamda bor.
Sourcepub const SIP_CODES: &[&str]
pub const SIP_CODES: &[&str]
SIP xizmat kodi.
Manba: ITU’ning 2023-02-10 dagi O’zbekiston E.164 rejasi.
Sourcepub const NON_GEOGRAPHIC_FIXED_CODES: &[&str]
pub const NON_GEOGRAPHIC_FIXED_CODES: &[&str]
Geografik bo’lmagan statsionar tarmoq xizmat kodi.
Manba: ITU’ning 2023-02-10 dagi O’zbekiston E.164 rejasi.
Sourcepub const REGIONAL_CODES: RangeInclusive<u8>
👎Deprecated: aniq hudud kodlari uchun PhoneNumber::GEOGRAPHIC_CODES dan foydalaning
pub const REGIONAL_CODES: RangeInclusive<u8>
aniq hudud kodlari uchun PhoneNumber::GEOGRAPHIC_CODES dan foydalaning
Eski shahar/hudud oralig’i; aniq tasnif uchun ishlatilmaydi.
Sourcepub fn parse_strict(value: &str) -> Result<Self, PhoneNumberError>
pub fn parse_strict(value: &str) -> Result<Self, PhoneNumberError>
Struktura + mobil/geografik/SIP/statsionar kod exact ro’yxatda bo’lishi shart.
Ro’yxat crate bilan birga keladi va eskirishi mumkin. DB/Kafka/Serde replay
uchun parse ni, o’z registringiz bo’lsa
operator_code ni ishlating.
Sourcepub fn operator_code(&self) -> &str
pub fn operator_code(&self) -> &str
Kod (90, 71) — xom, ro’yxatga qaramasdan.
Bu crate registridan chiqish yo’li: kod ajratmalari vaqt bilan o’zgaradi va
crate snapshot’i eskirishi mumkin. Joriy ro’yxat sizga config yoki DB’dan
kelsa, is_*() metodlarini emas, shu accessor’ni ishlating — parse()
strukturasi barqaror qoladi, siyosat esa sizniki bo’ladi:
use uz_types::PhoneNumber;
// Ro'yxat sizniki: config, DB yoki remote'dan keladi.
let allowed = ["90", "91", "99"];
let phone = PhoneNumber::parse("998911234567").unwrap();
assert!(allowed.contains(&phone.operator_code()));
// Crate registri hali bilmaydigan yangi kod ham shu yo'l bilan o'tadi.
let fresh = PhoneNumber::parse("998001234567").unwrap();
assert!(!fresh.is_known_operator());
assert_eq!(fresh.operator_code(), "00");Sourcepub fn subscriber_number(&self) -> &str
pub fn subscriber_number(&self) -> &str
Abonent raqami (1234567).
Sourcepub fn is_geographic(&self) -> bool
pub fn is_geographic(&self) -> bool
Kod crate’dagi aniq geografik PSTN ro’yxatida bormi.
Sourcepub fn is_non_geographic_fixed(&self) -> bool
pub fn is_non_geographic_fixed(&self) -> bool
Kod crate’dagi geografik bo’lmagan statsionar ro’yxatda bormi.
Sourcepub fn is_known_operator(&self) -> bool
pub fn is_known_operator(&self) -> bool
Kod crate’dagi aniq mobil, geografik, SIP yoki statsionar ro’yxatda bormi.
Bu crate snapshot’iga nisbatan javob, mutlaq haqiqat emas. Yangi kod
ajratilsa, crate yangilanmaguncha bu metod false qaytaradi va
parse_strict rad etadi — parse esa
ta’sirlanmaydi. Registrni o’zingiz boshqarmoqchi bo’lsangiz
operator_code misoliga qarang.
Sourcepub fn to_international(&self) -> String
pub fn to_international(&self) -> String
+998901234567 (yangi String).
Trait Implementations§
Source§impl AsRef<str> for PhoneNumber
impl AsRef<str> for PhoneNumber
Source§impl Borrow<str> for PhoneNumber
HashMap<$Name, V>::get("...") va BTreeMap uchun.
Hash/Eq/Ord ichki String dan derive qilingani uchun str bilan mos.
impl Borrow<str> for PhoneNumber
HashMap<$Name, V>::get("...") va BTreeMap uchun.
Hash/Eq/Ord ichki String dan derive qilingani uchun str bilan mos.
Source§impl Clone for PhoneNumber
impl Clone for PhoneNumber
Source§impl Debug for PhoneNumber
impl Debug for PhoneNumber
Source§impl<'r, DB: Database> Decode<'r, DB> for PhoneNumber
impl<'r, DB: Database> Decode<'r, DB> for PhoneNumber
Source§impl<'r, DB: Database> Decode<'r, DB> for PhoneNumber
impl<'r, DB: Database> Decode<'r, DB> for PhoneNumber
Source§impl<'de> Deserialize<'de> for PhoneNumber
Available on crate feature serde only.
impl<'de> Deserialize<'de> for PhoneNumber
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for PhoneNumber
impl Display for PhoneNumber
Source§impl<'q, DB: Database> Encode<'q, DB> for PhoneNumber
impl<'q, DB: Database> Encode<'q, DB> for PhoneNumber
Source§fn encode_by_ref(
&self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
Source§impl<'q, DB: Database> Encode<'q, DB> for PhoneNumber
impl<'q, DB: Database> Encode<'q, DB> for PhoneNumber
Source§fn encode_by_ref(
&self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer, ) -> Result<IsNull, BoxDynError>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
impl Eq for PhoneNumber
Source§impl From<PhoneNumber> for String
impl From<PhoneNumber> for String
Source§fn from(value: PhoneNumber) -> Self
fn from(value: PhoneNumber) -> Self
Source§impl FromStr for PhoneNumber
impl FromStr for PhoneNumber
Source§impl Hash for PhoneNumber
impl Hash for PhoneNumber
Source§impl Ord for PhoneNumber
impl Ord for PhoneNumber
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PhoneNumber
impl PartialEq for PhoneNumber
Source§impl PartialOrd for PhoneNumber
impl PartialOrd for PhoneNumber
Source§impl PgHasArrayType for PhoneNumberwhere
String: PgHasArrayType,
impl PgHasArrayType for PhoneNumberwhere
String: PgHasArrayType,
fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Source§impl PgHasArrayType for PhoneNumberwhere
String: PgHasArrayType,
impl PgHasArrayType for PhoneNumberwhere
String: PgHasArrayType,
fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Source§impl Serialize for PhoneNumber
Available on crate feature serde only.
impl Serialize for PhoneNumber
serde only.impl StructuralPartialEq for PhoneNumber
Source§impl TryFrom<&str> for PhoneNumber
impl TryFrom<&str> for PhoneNumber
Source§type Error = PhoneNumberError
type Error = PhoneNumberError
Source§impl TryFrom<String> for PhoneNumber
Yagona “owned” yo’l: hech qachon qo’shimcha allocation qilmaydi.
impl TryFrom<String> for PhoneNumber
Yagona “owned” yo’l: hech qachon qo’shimcha allocation qilmaydi.
Source§type Error = PhoneNumberError
type Error = PhoneNumberError
Source§impl<DB: Database> Type<DB> for PhoneNumber
impl<DB: Database> Type<DB> for PhoneNumber
Source§impl<DB: Database> Type<DB> for PhoneNumber
impl<DB: Database> Type<DB> for PhoneNumber
Auto Trait Implementations§
impl Freeze for PhoneNumber
impl RefUnwindSafe for PhoneNumber
impl Send for PhoneNumber
impl Sync for PhoneNumber
impl Unpin for PhoneNumber
impl UnsafeUnpin for PhoneNumber
impl UnwindSafe for PhoneNumber
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
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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