2 releases

Uses old Rust 2015

0.1.1 Nov 14, 2016
0.1.0 Nov 14, 2016

#378 in Internationalization (i18n)

MIT license

1MB
11K SLoC

Rust 9K SLoC // 0.0% comments C++ 2K SLoC

libphonenumber-sys

This is a very early atempt to create rust ffi bindings to googles excellent libphonenumber. Most of the crate has been autogenerated with cpp_to_rust from the current libphonenumber version 7.7 and then modified to work better with rusts native types. Many functions are not properly implemented yet, especially the ones that take or emit std::strings, as they require additional modifications to the c wrapper.

Example

use libphonenumber_sys::{PhoneNumberUtil,PhoneNumber,PhoneNumberFormat,PhoneNumberUtilError};

//get instance of PhoneNumberUtil
let util = PhoneNumberUtil::get_instance();

//construct a number by hand
let number1 = PhoneNumber::new();
number1.set_country_code(1);
number1.set_national_number(2128322000);

//check if number is valid
assert_eq!(util.is_valid_number(&number1), true);

//parse a number from a string
let number2 = util.parse("(800) 1234-5678","US").unwrap();

assert_eq!(number2.country_code(), 1);
assert_eq!(number2.national_number(), 80012345678);

//format a number as E164 string
let e164 = util.format(&number2, PhoneNumberFormat::E164);

assert_eq!(e164, "+180012345678");

Dependencies