1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Backend dependency metadata for standard-library mappings.
/// Backend crate required by a standard-library mapping.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[non_exhaustive]
pub enum BackendDependency {
/// `reqwest` for generated HTTP clients.
Reqwest,
/// `serde_json` for generated JSON parsing and serialization.
SerdeJson,
/// `regex` for generated regular-expression matching.
Regex,
/// `rand` for generated random values.
Rand,
/// `chrono` for generated date and datetime values.
Chrono,
/// `chrono-tz` for generated IANA time zone conversion.
ChronoTz,
/// `url` for generated URL parsing and field access.
Url,
/// `unicode-normalization` for generated `String.prototype.normalize`.
UnicodeNormalization,
}
impl BackendDependency {
/// Return the generated Cargo.toml dependency line for this backend crate.
#[must_use]
pub const fn cargo_dependency(self) -> &'static str {
match self {
Self::Reqwest => {
"reqwest = { version = \"0.12\", default-features = false, features = [\"blocking\", \"rustls-tls\"] }\n"
}
Self::SerdeJson => {
"serde = { version = \"1\", features = [\"derive\"] }\nserde_json = \"1\"\n"
}
Self::Regex => "regex = \"1\"\nfancy-regex = \"0.14\"\n",
Self::Rand => "rand = \"0.9\"\n",
Self::Chrono => "chrono = \"0.4\"\n",
Self::ChronoTz => "chrono-tz = \"0.10\"\n",
Self::Url => "url = \"2\"\n",
Self::UnicodeNormalization => "unicode-normalization = \"0.1\"\n",
}
}
}