Skip to content

Commit 1546318

Browse files
committed
Remove optional features from mas-iana & regenerate
Also ignores 'TEMPORARY' items in the IANA registry
1 parent fc6756d commit 1546318

File tree

8 files changed

+67
-57
lines changed

8 files changed

+67
-57
lines changed

crates/iana-codegen/src/generation.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ pub fn json_schema_impl(
164164
) -> std::fmt::Result {
165165
write!(
166166
f,
167-
r#"#[cfg(feature = "schemars")]
168-
impl schemars::JsonSchema for {} {{
167+
r#"impl schemars::JsonSchema for {} {{
169168
fn schema_name() -> String {{
170169
"{}".to_owned()
171170
}}
@@ -237,8 +236,7 @@ impl schemars::JsonSchema for {} {{
237236
pub fn serde_impl(f: &mut std::fmt::Formatter<'_>, section: &Section) -> std::fmt::Result {
238237
writeln!(
239238
f,
240-
r#"#[cfg(feature = "serde")]
241-
impl<'de> serde::Deserialize<'de> for {} {{
239+
r"impl<'de> serde::Deserialize<'de> for {} {{
242240
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
243241
where
244242
D: serde::de::Deserializer<'de>,
@@ -248,15 +246,14 @@ impl<'de> serde::Deserialize<'de> for {} {{
248246
}}
249247
}}
250248
251-
#[cfg(feature = "serde")]
252249
impl serde::Serialize for {} {{
253250
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
254251
where
255252
S: serde::ser::Serializer,
256253
{{
257254
serializer.serialize_str(&self.to_string())
258255
}}
259-
}}"#,
256+
}}",
260257
section.key, section.key,
261258
)
262259
}

crates/iana-codegen/src/jose.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum Requirements {
3131
RecommendedMinus,
3232
Optional,
3333
Prohibited,
34+
Deprecated,
3435
}
3536

3637
#[allow(dead_code)]
@@ -78,10 +79,18 @@ impl EnumEntry for WebEncryptionSignatureAlgorithm {
7879
if self.reference.contains("RFC7518, Section 3")
7980
|| self.reference.contains("RFC8037")
8081
|| self.reference.contains("RFC8812")
82+
|| (self
83+
.reference
84+
.contains("RFC-ietf-jose-fully-specified-algorithms")
85+
&& self.reference.contains("Section 2"))
8186
{
8287
Some("JsonWebSignatureAlg")
8388
} else if self.reference.contains("RFC7518, Section 4")
8489
|| self.reference.contains("WebCryptoAPI")
90+
|| (self
91+
.reference
92+
.contains("RFC-ietf-jose-fully-specified-algorithms")
93+
&& self.reference.contains("Section 3"))
8594
{
8695
Some("JsonWebEncryptionAlg")
8796
} else {

crates/iana-codegen/src/traits.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ pub trait EnumEntry: DeserializeOwned + Send + Sync {
8989
.into_deserialize()
9090
.filter_map(|item: Result<Self, _>| {
9191
item.map(|item| {
92+
if item
93+
.description()
94+
.is_some_and(|desc| desc.contains("TEMPORARY"))
95+
{
96+
return None;
97+
}
98+
9299
item.key().map(|key| {
93100
(
94101
key,

crates/iana/Cargo.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,5 @@ publish.workspace = true
1313
workspace = true
1414

1515
[dependencies]
16-
serde = { workspace = true, optional = true }
17-
schemars = { workspace = true, optional = true }
18-
19-
[features]
20-
default = ["serde", "schemars"]
21-
serde = ["dep:serde"]
22-
schemars = ["dep:schemars"]
16+
serde.workspace = true
17+
schemars.workspace = true

crates/iana/src/jose.rs

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ pub enum JsonWebSignatureAlg {
6262
/// ECDSA using secp256k1 curve and SHA-256
6363
Es256K,
6464

65+
/// EdDSA using Ed25519 curve
66+
Ed25519,
67+
68+
/// EdDSA using Ed448 curve
69+
Ed448,
70+
6571
/// An unknown value.
6672
Unknown(String),
6773
}
@@ -84,6 +90,8 @@ impl core::fmt::Display for JsonWebSignatureAlg {
8490
Self::None => write!(f, "none"),
8591
Self::EdDsa => write!(f, "EdDSA"),
8692
Self::Es256K => write!(f, "ES256K"),
93+
Self::Ed25519 => write!(f, "Ed25519"),
94+
Self::Ed448 => write!(f, "Ed448"),
8795
Self::Unknown(value) => write!(f, "{value}"),
8896
}
8997
}
@@ -109,12 +117,13 @@ impl core::str::FromStr for JsonWebSignatureAlg {
109117
"none" => Ok(Self::None),
110118
"EdDSA" => Ok(Self::EdDsa),
111119
"ES256K" => Ok(Self::Es256K),
120+
"Ed25519" => Ok(Self::Ed25519),
121+
"Ed448" => Ok(Self::Ed448),
112122
value => Ok(Self::Unknown(value.to_owned())),
113123
}
114124
}
115125
}
116126

117-
#[cfg(feature = "serde")]
118127
impl<'de> serde::Deserialize<'de> for JsonWebSignatureAlg {
119128
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
120129
where
@@ -125,7 +134,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebSignatureAlg {
125134
}
126135
}
127136

128-
#[cfg(feature = "serde")]
129137
impl serde::Serialize for JsonWebSignatureAlg {
130138
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
131139
where
@@ -135,7 +143,6 @@ impl serde::Serialize for JsonWebSignatureAlg {
135143
}
136144
}
137145

138-
#[cfg(feature = "schemars")]
139146
impl schemars::JsonSchema for JsonWebSignatureAlg {
140147
fn schema_name() -> String {
141148
"JsonWebSignatureAlg".to_owned()
@@ -339,6 +346,32 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
339346
..Default::default()
340347
}
341348
.into(),
349+
// ---
350+
schemars::schema::SchemaObject {
351+
metadata: Some(Box::new(schemars::schema::Metadata {
352+
description: Some(
353+
// ---
354+
r"EdDSA using Ed25519 curve".to_owned(),
355+
),
356+
..Default::default()
357+
})),
358+
const_value: Some("Ed25519".into()),
359+
..Default::default()
360+
}
361+
.into(),
362+
// ---
363+
schemars::schema::SchemaObject {
364+
metadata: Some(Box::new(schemars::schema::Metadata {
365+
description: Some(
366+
// ---
367+
r"EdDSA using Ed448 curve".to_owned(),
368+
),
369+
..Default::default()
370+
})),
371+
const_value: Some("Ed448".into()),
372+
..Default::default()
373+
}
374+
.into(),
342375
];
343376

344377
let description = r#"JSON Web Signature "alg" parameter"#;
@@ -480,7 +513,6 @@ impl core::str::FromStr for JsonWebEncryptionAlg {
480513
}
481514
}
482515

483-
#[cfg(feature = "serde")]
484516
impl<'de> serde::Deserialize<'de> for JsonWebEncryptionAlg {
485517
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
486518
where
@@ -491,7 +523,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebEncryptionAlg {
491523
}
492524
}
493525

494-
#[cfg(feature = "serde")]
495526
impl serde::Serialize for JsonWebEncryptionAlg {
496527
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
497528
where
@@ -501,7 +532,6 @@ impl serde::Serialize for JsonWebEncryptionAlg {
501532
}
502533
}
503534

504-
#[cfg(feature = "schemars")]
505535
impl schemars::JsonSchema for JsonWebEncryptionAlg {
506536
fn schema_name() -> String {
507537
"JsonWebEncryptionAlg".to_owned()
@@ -833,7 +863,6 @@ impl core::str::FromStr for JsonWebEncryptionEnc {
833863
}
834864
}
835865

836-
#[cfg(feature = "serde")]
837866
impl<'de> serde::Deserialize<'de> for JsonWebEncryptionEnc {
838867
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
839868
where
@@ -844,7 +873,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebEncryptionEnc {
844873
}
845874
}
846875

847-
#[cfg(feature = "serde")]
848876
impl serde::Serialize for JsonWebEncryptionEnc {
849877
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
850878
where
@@ -854,7 +882,6 @@ impl serde::Serialize for JsonWebEncryptionEnc {
854882
}
855883
}
856884

857-
#[cfg(feature = "schemars")]
858885
impl schemars::JsonSchema for JsonWebEncryptionEnc {
859886
fn schema_name() -> String {
860887
"JsonWebEncryptionEnc".to_owned()
@@ -992,7 +1019,6 @@ impl core::str::FromStr for JsonWebEncryptionCompressionAlgorithm {
9921019
}
9931020
}
9941021

995-
#[cfg(feature = "serde")]
9961022
impl<'de> serde::Deserialize<'de> for JsonWebEncryptionCompressionAlgorithm {
9971023
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
9981024
where
@@ -1003,7 +1029,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebEncryptionCompressionAlgorithm {
10031029
}
10041030
}
10051031

1006-
#[cfg(feature = "serde")]
10071032
impl serde::Serialize for JsonWebEncryptionCompressionAlgorithm {
10081033
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
10091034
where
@@ -1013,7 +1038,6 @@ impl serde::Serialize for JsonWebEncryptionCompressionAlgorithm {
10131038
}
10141039
}
10151040

1016-
#[cfg(feature = "schemars")]
10171041
impl schemars::JsonSchema for JsonWebEncryptionCompressionAlgorithm {
10181042
fn schema_name() -> String {
10191043
"JsonWebEncryptionCompressionAlgorithm".to_owned()
@@ -1101,7 +1125,6 @@ impl core::str::FromStr for JsonWebKeyType {
11011125
}
11021126
}
11031127

1104-
#[cfg(feature = "serde")]
11051128
impl<'de> serde::Deserialize<'de> for JsonWebKeyType {
11061129
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
11071130
where
@@ -1112,7 +1135,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyType {
11121135
}
11131136
}
11141137

1115-
#[cfg(feature = "serde")]
11161138
impl serde::Serialize for JsonWebKeyType {
11171139
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
11181140
where
@@ -1122,7 +1144,6 @@ impl serde::Serialize for JsonWebKeyType {
11221144
}
11231145
}
11241146

1125-
#[cfg(feature = "schemars")]
11261147
impl schemars::JsonSchema for JsonWebKeyType {
11271148
fn schema_name() -> String {
11281149
"JsonWebKeyType".to_owned()
@@ -1249,7 +1270,6 @@ impl core::str::FromStr for JsonWebKeyEcEllipticCurve {
12491270
}
12501271
}
12511272

1252-
#[cfg(feature = "serde")]
12531273
impl<'de> serde::Deserialize<'de> for JsonWebKeyEcEllipticCurve {
12541274
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
12551275
where
@@ -1260,7 +1280,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyEcEllipticCurve {
12601280
}
12611281
}
12621282

1263-
#[cfg(feature = "serde")]
12641283
impl serde::Serialize for JsonWebKeyEcEllipticCurve {
12651284
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
12661285
where
@@ -1270,7 +1289,6 @@ impl serde::Serialize for JsonWebKeyEcEllipticCurve {
12701289
}
12711290
}
12721291

1273-
#[cfg(feature = "schemars")]
12741292
impl schemars::JsonSchema for JsonWebKeyEcEllipticCurve {
12751293
fn schema_name() -> String {
12761294
"JsonWebKeyEcEllipticCurve".to_owned()
@@ -1397,7 +1415,6 @@ impl core::str::FromStr for JsonWebKeyOkpEllipticCurve {
13971415
}
13981416
}
13991417

1400-
#[cfg(feature = "serde")]
14011418
impl<'de> serde::Deserialize<'de> for JsonWebKeyOkpEllipticCurve {
14021419
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
14031420
where
@@ -1408,7 +1425,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyOkpEllipticCurve {
14081425
}
14091426
}
14101427

1411-
#[cfg(feature = "serde")]
14121428
impl serde::Serialize for JsonWebKeyOkpEllipticCurve {
14131429
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
14141430
where
@@ -1418,7 +1434,6 @@ impl serde::Serialize for JsonWebKeyOkpEllipticCurve {
14181434
}
14191435
}
14201436

1421-
#[cfg(feature = "schemars")]
14221437
impl schemars::JsonSchema for JsonWebKeyOkpEllipticCurve {
14231438
fn schema_name() -> String {
14241439
"JsonWebKeyOkpEllipticCurve".to_owned()
@@ -1535,7 +1550,6 @@ impl core::str::FromStr for JsonWebKeyUse {
15351550
}
15361551
}
15371552

1538-
#[cfg(feature = "serde")]
15391553
impl<'de> serde::Deserialize<'de> for JsonWebKeyUse {
15401554
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
15411555
where
@@ -1546,7 +1560,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyUse {
15461560
}
15471561
}
15481562

1549-
#[cfg(feature = "serde")]
15501563
impl serde::Serialize for JsonWebKeyUse {
15511564
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
15521565
where
@@ -1556,7 +1569,6 @@ impl serde::Serialize for JsonWebKeyUse {
15561569
}
15571570
}
15581571

1559-
#[cfg(feature = "schemars")]
15601572
impl schemars::JsonSchema for JsonWebKeyUse {
15611573
fn schema_name() -> String {
15621574
"JsonWebKeyUse".to_owned()
@@ -1677,7 +1689,6 @@ impl core::str::FromStr for JsonWebKeyOperation {
16771689
}
16781690
}
16791691

1680-
#[cfg(feature = "serde")]
16811692
impl<'de> serde::Deserialize<'de> for JsonWebKeyOperation {
16821693
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
16831694
where
@@ -1688,7 +1699,6 @@ impl<'de> serde::Deserialize<'de> for JsonWebKeyOperation {
16881699
}
16891700
}
16901701

1691-
#[cfg(feature = "serde")]
16921702
impl serde::Serialize for JsonWebKeyOperation {
16931703
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
16941704
where
@@ -1698,7 +1708,6 @@ impl serde::Serialize for JsonWebKeyOperation {
16981708
}
16991709
}
17001710

1701-
#[cfg(feature = "schemars")]
17021711
impl schemars::JsonSchema for JsonWebKeyOperation {
17031712
fn schema_name() -> String {
17041713
"JsonWebKeyOperation".to_owned()

0 commit comments

Comments
 (0)