Skip to content

Commit bbb321e

Browse files
asdf
1 parent 9e997b6 commit bbb321e

File tree

1 file changed

+24
-12
lines changed
  • codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize

1 file changed

+24
-12
lines changed

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/SerdeDecorator.kt

+24-12
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection
1515
import software.amazon.smithy.rust.codegen.core.smithy.generators.ModuleDocSection
1616

1717
/**
18-
* This class,
19-
* - Adds serde as a dependency
20-
*
18+
* Decorator that adds the `serde-serialize` and `serde-deserialize` features.
2119
*/
2220
class SerdeDecorator : ClientCodegenDecorator {
2321
override val name: String = "SerdeDecorator"
@@ -38,17 +36,31 @@ class SerdeDecorator : ClientCodegenDecorator {
3836
}
3937

4038
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+
}
4161
override fun section(section: LibRsSection): Writable {
4262
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() }
5264
} else {
5365
emptySection
5466
}

0 commit comments

Comments
 (0)