pub enum MobileNetwork {
Globe(Globe),
Smart(Smart),
Sun(Sun),
TNT(TNT),
Dito(Dito),
Invalid(String),
}Variants§
Implementations§
Source§impl MobileNetwork
impl MobileNetwork
Sourcepub fn get(number: &str) -> Result<Self, MobileNetworkError>
pub fn get(number: &str) -> Result<Self, MobileNetworkError>
Examples found in repository?
examples/main.rs (line 25)
6fn main() {
7 // if for some reason the default library prefixes has invalid values you can always reset it
8 reset_dito_prefixes();
9 reset_globe_prefixes();
10 reset_smart_prefixes();
11 reset_sun_prefixes();
12 reset_tnt_prefixes();
13 // if the current prefix isnt supported yet by the library you can always append it on compile time
14 // append new prefixes on different networks
15 append_dito_prefixes(&["0911", "0912"]); // Adding new TNT prefixes
16 append_globe_prefixes(&["0917", "0996"]); // Adding new Globe prefixes
17 append_smart_prefixes(&["0918", "0919"]); // Adding new Smart prefixes
18 append_sun_prefixes(&["0933", "0934"]); // Adding new Sun prefixes
19 append_tnt_prefixes(&["0899", "0900"]); // Adding new Dito prefixes
20
21 // Example phone number to validate
22 let number = "09171234567";
23
24 // Get the network based on the phone number and validate the number
25 match MobileNetwork::get(number) {
26 Ok(network) => {
27 println!("Network identified: {}", network.to_string());
28 match network.validate(number) {
29 Ok(valid) => println!("Validation result: {}", valid),
30 Err(e) => println!("Validation error: {:?}", e),
31 }
32 },
33 Err(e) => println!("Error retrieving network: {:?}", e),
34 }
35}Trait Implementations§
Source§impl Display for MobileNetwork
impl Display for MobileNetwork
Auto Trait Implementations§
impl Freeze for MobileNetwork
impl RefUnwindSafe for MobileNetwork
impl Send for MobileNetwork
impl Sync for MobileNetwork
impl Unpin for MobileNetwork
impl UnwindSafe for MobileNetwork
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
Mutably borrows from an owned value. Read more