Expand description
§Phonelib
A comprehensive Rust library for handling phone numbers.
§Features
- Validation - Check if phone numbers are valid
- Country Detection - Extract country information from phone numbers
- Normalization - Clean and standardize phone number formats
- Multiple Format Support - E.164, International, National, RFC3966
- Type Detection - Identify mobile, landline, toll-free, premium numbers
- Text Extraction - Parse phone numbers from free-form text
- Comparison/Equality - Compare numbers regardless of format
- Batch Processing - Process multiple numbers efficiently
§Quick Start
use phonelib::*;
// Basic validation
let is_valid = is_valid_phone_number("+12025550173".to_string());
assert!(is_valid);
// Normalize a number
let normalized = normalize_phone_number("12025550173".to_string());
assert_eq!(normalized, Some("+12025550173".to_string()));
// Extract phone numbers from text
let text = "Call me at +12025550173 or +442079460958";
let numbers = extract_phone_numbers_from_text(text);
assert_eq!(numbers.len(), 2);
// Compare phone numbers (different formats, same number)
let num1 = PhoneNumber::parse("+12025550173").unwrap();
let num2 = PhoneNumber::parse("12025550173").unwrap();
assert_eq!(num1, num2);Structs§
- Extracted
Phone Number - Result of extracting a phone number from text
- Phone
Number - A parsed and validated phone number with equality comparison
- Phone
Number Analysis - Detailed analysis result for a phone number
- Phone
Number Set - A collection of phone numbers that can be compared and deduplicated
Enums§
- Phone
Format - Phone number format options
- Phone
Number Type - Phone number types
Functions§
- analyze_
phone_ numbers_ batch - Comprehensive batch analysis of phone numbers
- are_
phone_ numbers_ equal - Check if two phone numbers are equivalent (same number, different formats)
- count_
phone_ numbers_ in_ text - Count how many phone numbers are in the text
- detect_
phone_ number_ type - Detect the type of a phone number (mobile, landline, toll-free, etc.)
- detect_
phone_ number_ types_ batch - Detect phone number types for multiple numbers at once
- extract_
countries_ batch - Extract countries for multiple phone numbers at once
- extract_
country - Extracts country information from a phone number.
- extract_
phone_ numbers_ from_ text - Extract all phone numbers from free-form text
- extract_
phone_ numbers_ with_ country_ hint - Extract phone numbers from text with a country hint
- extract_
valid_ phone_ numbers_ from_ text - Extract only valid phone numbers from text
- format_
phone_ number - Format a phone number according to the specified format
- generate_
random_ phone_ number - Generate a random valid phone number for a specific country
- generate_
random_ phone_ numbers - Generate multiple random valid phone numbers for a specific country
- group_
equivalent_ phone_ numbers - Compare multiple phone numbers and group them by equivalence
- guess_
country_ from_ number - Get the most likely country for a phone number based on patterns
- is_
landline_ number - Check if a phone number is a landline number
- is_
mobile_ number - Check if a phone number is a mobile number
- is_
potentially_ valid_ phone_ number - Check if a phone number is potentially valid but incorrectly formatted
- is_
toll_ free_ number - Check if a phone number is a toll-free number
- is_
valid_ phone_ number - Validates whether a phone number is valid.
- normalize_
phone_ number - Normalizes a phone number to E.164 format.
- normalize_
phone_ number_ in_ place - Normalizes a phone number in place to E.164 format.
- normalize_
phone_ numbers_ batch - Normalize multiple phone numbers at once
- redact_
phone_ numbers - Redact (mask) phone numbers in text for privacy
- replace_
phone_ numbers_ in_ text - Replace phone numbers in text with a placeholder or transformed version
- suggest_
phone_ number_ corrections - Suggest corrections for an invalid phone number
- validate_
phone_ numbers_ batch - Validate multiple phone numbers at once