codes_iana_charset/lib.rs
1/*!
2This package contains an implementation of the
3[IANA CHARSET](https://www.iana.org/assignments/character-sets/character-sets.xhtml) specification.
4
5These are the official names for character sets that may be used in
6the Internet and may be referred to in Internet documentation. These
7names are expressed in ANSI_X3.4-1968 which is commonly called
8US-ASCII or simply ASCII. The character set most commonly use in the
9Internet and used especially in protocol standards is US-ASCII, this
10is strongly encouraged. The use of the name US-ASCII is also
11encouraged.
12
13The character set names may be up to 40 characters taken from the
14printable characters of US-ASCII. However, no distinction is made
15between use of upper and lower case letters.
16
17The MIBenum value is a unique value for use in MIBs to identify coded
18character sets.
19
20The value space for MIBenum values has been divided into three
21regions. The first region (3-999) consists of coded character sets
22that have been standardized by some standard setting organization.
23This region is intended for standards that do not have subset
24implementations. The second region (1000-1999) is for the Unicode and
25ISO/IEC 10646 coded character sets together with a specification of a
26(set of) sub-repertoires that may occur. The third region (>1999) is
27intended for vendor specific coded character sets.
28
29# Example
30
31```rust
32use codes_iana_charset as charset;
33
34let latin_1 = charset::CHARSET_4;
35assert_eq!(latin_1.id(), 4);
36assert_eq!(latin_1.name(), "ISO_8859-1:1987");
37assert_eq!(
38 latin_1.source(),
39 "[ISO-IR: International Register of Escape Sequences] Note: The current registration authority is IPSJ/ITSCJ, Japan.",
40);
41assert_eq!(latin_1.preferred_alias(), Some("ISO-8859-1"));
42assert_eq!(latin_1.aliases(), &[
43 "iso-ir-100",
44 "ISO_8859-1",
45 "ISO-8859-1",
46 "latin1",
47 "l1",
48 "IBM819",
49 "CP819",
50 "csISOLatin1"
51]);
52assert_eq!(latin_1.reference(), Some("[RFC1345][Keld_Simonsen]"));
53```
54Note that the implementation of `FromStr` takes into account all aliases.
55
56```rust
57use codes_iana_charset as charset;
58use std::str::FromStr;
59
60let latin_1 = charset::CHARSET_4;
61
62let iso_8859_1 = charset::CharacterSetCode::from_str("ISO_8859-1").unwrap();
63
64assert_eq!(latin_1, iso_8859_1);
65
66let some_charset = charset::CharacterSetCode::try_from(4).unwrap();
67
68assert_eq!(some_charset, iso_8859_1);
69```
70
71# Features
72
73*/
74
75#![warn(
76 unknown_lints,
77 // ---------- Stylistic
78 absolute_paths_not_starting_with_crate,
79 elided_lifetimes_in_paths,
80 explicit_outlives_requirements,
81 macro_use_extern_crate,
82 nonstandard_style, /* group */
83 noop_method_call,
84 rust_2018_idioms,
85 single_use_lifetimes,
86 trivial_casts,
87 trivial_numeric_casts,
88 // ---------- Future
89 future_incompatible, /* group */
90 rust_2021_compatibility, /* group */
91 // ---------- Public
92 missing_debug_implementations,
93 // missing_docs,
94 unreachable_pub,
95 // ---------- Unsafe
96 unsafe_code,
97 unsafe_op_in_unsafe_fn,
98 // ---------- Unused
99 unused, /* group */
100)]
101#![deny(
102 // ---------- Public
103 exported_private_dependencies,
104 private_in_public,
105 // ---------- Deprecated
106 anonymous_parameters,
107 bare_trait_objects,
108 ellipsis_inclusive_range_patterns,
109 // ---------- Unsafe
110 deref_nullptr,
111 drop_bounds,
112 dyn_drop,
113)]
114
115// ------------------------------------------------------------------------------------------------
116//
117// The rest of this file is generated by the package build script.
118//
119// ------------------------------------------------------------------------------------------------
120
121include!(concat!(env!("OUT_DIR"), "/generated.rs"));