codes_iso_3166/
lib.rs

1/*!
2This package contains an implementation of the [ISO
33166](https://www.iso.org/iso-3166-country-codes.html), parts 1 and 2,
4standard.
5
6The purpose of ISO 3166 is to define internationally recognized codes of
7letters and/or numbers that we can use when we refer to countries and their
8subdivisions. However, it does not define the names of countries – this
9information comes from United Nations sources (Terminology Bulletin Country
10Names and the Country and Region Codes for Statistical Use maintained by the
11United Nations Statistics Divisions).
12
13The country codes can be represented either as a two-letter code (alpha-2)
14which is recommended as the general-purpose code, a three-letter code
15(alpha-3) which is more closely related to the country name and a three-digit
16numeric code (numeric-3) which can be useful if you need to avoid using Latin
17script.
18
19# Example
20
21This example shows the use of the part-1 Country Code.
22
23```rust
24use codes_iso_3166::part_1::CountryCode;
25use std::str::FromStr;
26
27let country = CountryCode::from_str("AG").unwrap();
28
29assert_eq!(country.alpha_2_code(), "AG");
30assert_eq!(country.short_name(), "Antigua and Barbuda");
31```
32
33# Features
34
35By default only the `serde` feature is enabled, and [part_1] two-letter
36language codes.
37
38* `serde` - Enables serialization of the different Language Code types.
39* `alpha_3_code` - Adds the `CountryCode::alpha_3_code` method.
40* `numeric_code` - Adds the `CountryCode::numeric_code` method.
41* `independent` - Adds the `CountryCode::independent` method.
42* `status` - Adds the `CountryCode::status` method.
43* `full_name` - Adds the `CountryCode::full_name` method.
44* `local_names` - Adds the `CountryCode::local_short_name` and
45  `CountryCode::local_full_name` methods.
46* `languages`  - Adds the `CountryCode::administrative_language` and `CountryCode::languages` methods (requires package `codes-iso-639`).
47* `formerly` - Adds the `CountryCode::former_short_name` and
48  `CountryCode::former_alpha_3_code` methods.
49* `part_2` - Adds the corresponding module and `SubdivisionCode`.
50  * `categories` - Adds the `SubdivisionCode::category_code` method and `SubdivisionCategoryCode` type.
51  * `territories` - Adds the `TerritoryCode` type.
52  * `languages` - Adds the `SubdivisionCode::name_language` method.
53
54Note that the method `CountryCode::local_full_name` requires both
55`local_names` and `full_name` features.
56
57*/
58
59#![warn(
60    unknown_lints,
61    // ---------- Stylistic
62    absolute_paths_not_starting_with_crate,
63    elided_lifetimes_in_paths,
64    explicit_outlives_requirements,
65    macro_use_extern_crate,
66    nonstandard_style, /* group */
67    noop_method_call,
68    rust_2018_idioms,
69    single_use_lifetimes,
70    trivial_casts,
71    trivial_numeric_casts,
72    // ---------- Future
73    future_incompatible, /* group */
74    rust_2021_compatibility, /* group */
75    // ---------- Public
76    missing_debug_implementations,
77    // missing_docs,
78    unreachable_pub,
79    // ---------- Unsafe
80    unsafe_code,
81    unsafe_op_in_unsafe_fn,
82    // ---------- Unused
83    unused, /* group */
84)]
85#![deny(
86    // ---------- Public
87    exported_private_dependencies,
88    private_in_public,
89    // ---------- Deprecated
90    anonymous_parameters,
91    bare_trait_objects,
92    ellipsis_inclusive_range_patterns,
93    // ---------- Unsafe
94    deref_nullptr,
95    drop_bounds,
96    dyn_drop,
97)]
98
99// ------------------------------------------------------------------------------------------------
100// Public Types
101// ------------------------------------------------------------------------------------------------
102
103pub use codes_common::CodeParseError as CountryCodeError;
104
105// ------------------------------------------------------------------------------------------------
106// Modules
107// ------------------------------------------------------------------------------------------------
108
109pub mod part_1;
110
111#[cfg(feature = "part_2")]
112pub mod part_2;