@@ -15,9 +15,7 @@ import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection
15
15
import software.amazon.smithy.rust.codegen.core.smithy.generators.ModuleDocSection
16
16
17
17
/* *
18
- * This class,
19
- * - Adds serde as a dependency
20
- *
18
+ * Decorator that adds the `serde-serialize` and `serde-deserialize` features.
21
19
*/
22
20
class SerdeDecorator : ClientCodegenDecorator {
23
21
override val name: String = " SerdeDecorator"
@@ -38,17 +36,31 @@ class SerdeDecorator : ClientCodegenDecorator {
38
36
}
39
37
40
38
class SerdeDocGenerator (private val codegenContext : ClientCodegenContext ) : LibRsCustomization() {
39
+ companion object {
40
+ const val SerdeInfoText = """ ## How to enable `Serialize` and `Deserialize`
41
+
42
+ This data type implements `Serialize` and `Deserialize` traits from the popular serde crate,
43
+ but those traits are behind feature gate.
44
+
45
+ As they increase it's compile time dramatically, you should not turn them on unless it's necessary.
46
+ Furthermore, implementation of serde is still unstable, and implementation may change anytime in future.
47
+
48
+ To enable traits, you must pass `aws_sdk_unstable` to RUSTFLAGS and enable `serde-serialize` or `serde-deserialize` feature.
49
+
50
+ e.g.
51
+ ```bash,no_run
52
+ export RUSTFLAGS="--cfg aws_sdk_unstable"
53
+ cargo build --features serde-serialize serde-deserialize
54
+ ```
55
+
56
+ If you enable `serde-serialize` and/or `serde-deserialize` without `RUSTFLAGS="--cfg aws_sdk_unstable"`,
57
+ compilation will fail with warning.
58
+
59
+ """
60
+ }
41
61
override fun section (section : LibRsSection ): Writable {
42
62
return if (section is LibRsSection .ModuleDoc && section.subsection is ModuleDocSection .UnstableFeature ) {
43
- writable {
44
- """
45
- ## How to enable `Serialize` and `Deserialize`
46
- This data type implements `Serialize` and `Deserialize` traits from the popular serde crate,
47
- but those traits are behind feature gate.
48
-
49
- As they increase it's compile time dramatically, you should not turn them on unless it's necessary.
50
- """ .trimIndent()
51
- }
63
+ writable { SerdeInfoText .trimIndent() }
52
64
} else {
53
65
emptySection
54
66
}
0 commit comments