From 76a8d4857f25bf8eb6475aae422db313b9b982f4 Mon Sep 17 00:00:00 2001 From: Vlasislav Kashin <99754299+vloldik@users.noreply.github.com> Date: Sun, 13 Jul 2025 21:24:52 +0300 Subject: [PATCH] Refactor exports and imports --- src/interfaces/mod.rs | 2 +- src/lib.rs | 18 ++-------- src/phonenumberutil/helper_functions.rs | 11 ++++--- src/phonenumberutil/mod.rs | 1 - src/phonenumberutil/phonenumberutil.rs | 44 ++++++++++++++----------- src/regex_based_matcher.rs | 2 +- 6 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/interfaces/mod.rs b/src/interfaces/mod.rs index d4f41c0..302e6fb 100644 --- a/src/interfaces/mod.rs +++ b/src/interfaces/mod.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::PhoneNumberDesc; +use crate::generated::proto::phonemetadata::PhoneNumberDesc; /// Internal phonenumber matching API used to isolate the underlying /// implementation of the matcher and allow different implementations to be diff --git a/src/lib.rs b/src/lib.rs index 0f63064..cedf7e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,22 +41,8 @@ pub use phonenumberutil::{ ExtractNumberResult, PhoneNumberUtil }, - errors::{ - ExtractNumberError, - GetExampleNumberError, - ParseError, - NotANumberError, - ValidationError, - InternalLogicError, - InvalidNumberError, - InvalidMetadataForValidRegionError - }, - enums::{ - MatchType, - PhoneNumberType, - NumberLengthType, - PhoneNumberFormat - }, + errors::{*}, + enums::{*}, }; pub use generated::proto::phonemetadata::{*}; pub use generated::proto::phonenumber::PhoneNumber; diff --git a/src/phonenumberutil/helper_functions.rs b/src/phonenumberutil/helper_functions.rs index 15ac854..c99b857 100644 --- a/src/phonenumberutil/helper_functions.rs +++ b/src/phonenumberutil/helper_functions.rs @@ -20,13 +20,16 @@ use strum::IntoEnumIterator; use crate::{ interfaces::MatcherApi, generated::metadata::METADATA, - PhoneMetadata, PhoneMetadataCollection, PhoneNumberDesc, - PhoneNumber, - + generated::proto::{ + phonemetadata::{ + PhoneMetadata, PhoneMetadataCollection, PhoneNumberDesc + }, + phonenumber::PhoneNumber, + } }; use super::{ - PhoneNumberFormat, PhoneNumberType, NumberLengthType, + enums::{PhoneNumberFormat, PhoneNumberType, NumberLengthType}, errors::ValidationError, helper_constants::{ OPTIONAL_EXT_SUFFIX, PLUS_SIGN, POSSIBLE_CHARS_AFTER_EXT_LABEL, diff --git a/src/phonenumberutil/mod.rs b/src/phonenumberutil/mod.rs index 7d85cea..f870e81 100644 --- a/src/phonenumberutil/mod.rs +++ b/src/phonenumberutil/mod.rs @@ -23,7 +23,6 @@ pub(self) mod helper_types; use std::sync::LazyLock; -pub use enums::{MatchType, PhoneNumberFormat, PhoneNumberType, NumberLengthType}; use crate::phonenumberutil::phonenumberutil::PhoneNumberUtil; /// Singleton instance of phone number util for general use diff --git a/src/phonenumberutil/phonenumberutil.rs b/src/phonenumberutil/phonenumberutil.rs index 2849dda..4e39abe 100644 --- a/src/phonenumberutil/phonenumberutil.rs +++ b/src/phonenumberutil/phonenumberutil.rs @@ -19,26 +19,32 @@ use std::{ sync::Arc, }; -use super::phone_number_regexps_and_mappings::PhoneNumberRegExpsAndMappings; +use super::{ + phone_number_regexps_and_mappings::PhoneNumberRegExpsAndMappings, + helper_constants::{ + DEFAULT_EXTN_PREFIX, MAX_LENGTH_COUNTRY_CODE, MAX_LENGTH_FOR_NSN, MIN_LENGTH_FOR_NSN, + NANPA_COUNTRY_CODE, PLUS_SIGN, REGION_CODE_FOR_NON_GEO_ENTITY, RFC3966_EXTN_PREFIX, + RFC3966_ISDN_SUBADDRESS, RFC3966_PHONE_CONTEXT, RFC3966_PREFIX, + }, helper_functions::{ + self, copy_core_fields_only, get_number_desc_by_type, get_supported_types_for_metadata, + is_national_number_suffix_of_the_other, load_compiled_metadata, normalize_helper, + prefix_number_with_country_calling_code, test_number_length, + test_number_length_with_unknown_type, + }, + helper_types::{PhoneNumberWithCountryCodeSource}, + enums::{MatchType, PhoneNumberFormat, PhoneNumberType, NumberLengthType}, + errors::{ + ExtractNumberError, GetExampleNumberError, InternalLogicError, + InvalidMetadataForValidRegionError, InvalidNumberError, ParseError, + ValidationError, NotANumberError + }, +}; use crate::{ - region_code::RegionCode, interfaces::MatcherApi, macros::owned_from_cow_or, PhoneMetadataCollection, phonenumberutil::{ - errors::{ - ExtractNumberError, GetExampleNumberError, InternalLogicError, - InvalidMetadataForValidRegionError, InvalidNumberError, ParseError, - ValidationError, NotANumberError - }, helper_constants::{ - DEFAULT_EXTN_PREFIX, MAX_LENGTH_COUNTRY_CODE, MAX_LENGTH_FOR_NSN, MIN_LENGTH_FOR_NSN, - NANPA_COUNTRY_CODE, PLUS_SIGN, REGION_CODE_FOR_NON_GEO_ENTITY, RFC3966_EXTN_PREFIX, - RFC3966_ISDN_SUBADDRESS, RFC3966_PHONE_CONTEXT, RFC3966_PREFIX, - }, helper_functions::{ - self, copy_core_fields_only, get_number_desc_by_type, get_supported_types_for_metadata, - is_national_number_suffix_of_the_other, load_compiled_metadata, normalize_helper, - prefix_number_with_country_calling_code, test_number_length, - test_number_length_with_unknown_type, - }, helper_types::{PhoneNumberWithCountryCodeSource}, MatchType, PhoneNumberFormat, PhoneNumberType, NumberLengthType - }, - NumberFormat, PhoneMetadata, PhoneNumberDesc, - CountryCodeSource, PhoneNumber, + generated::proto::{ + phonemetadata::{PhoneMetadataCollection, NumberFormat, PhoneMetadata, PhoneNumberDesc}, + phonenumber::{phone_number::CountryCodeSource, PhoneNumber} + }, + region_code::RegionCode, interfaces::MatcherApi, macros::owned_from_cow_or, regex_based_matcher::RegexBasedMatcher, regex_util::{RegexConsume, RegexFullMatch}, regexp_cache::ErrorInvalidRegex, string_util::strip_cow_prefix }; diff --git a/src/regex_based_matcher.rs b/src/regex_based_matcher.rs index 1723c6a..a4a2d12 100644 --- a/src/regex_based_matcher.rs +++ b/src/regex_based_matcher.rs @@ -17,7 +17,7 @@ use log::{error}; use super::regex_util::{RegexFullMatch, RegexConsume}; -use crate::{interfaces, PhoneNumberDesc, regexp_cache::{ErrorInvalidRegex, RegexCache}}; +use crate::{interfaces, generated::proto::phonemetadata::PhoneNumberDesc, regexp_cache::{ErrorInvalidRegex, RegexCache}}; pub struct RegexBasedMatcher { cache: RegexCache,