File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -471,6 +471,10 @@ class Attribute(val inner: Writable) {
471
471
return Attribute (serde(" skip" ))
472
472
}
473
473
474
+ public fun SerdeSerializeOrDeserialize (): Attribute {
475
+ return Attribute (cfgAttr(all(writable(" aws_sdk_unstable" ), any(feature(" serde-serialize" ), feature(" serde-deserialize" )))))
476
+ }
477
+
474
478
companion object {
475
479
val AllowClippyBoxedLocal = Attribute (allow(" clippy::boxed_local" ))
476
480
val AllowClippyLetAndReturn = Attribute (allow(" clippy::let_and_return" ))
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ package software.amazon.smithy.rust.codegen.core.rustlang
8
8
import org.intellij.lang.annotations.Language
9
9
import org.jsoup.Jsoup
10
10
import org.jsoup.nodes.Element
11
+ import software.amazon.smithy.rust.codegen.core.smithy.generators.RenderSerdeAttribute
11
12
import software.amazon.smithy.codegen.core.CodegenException
12
13
import software.amazon.smithy.codegen.core.Symbol
13
14
import software.amazon.smithy.codegen.core.SymbolDependencyContainer
@@ -453,7 +454,9 @@ class RustWriter private constructor(
453
454
fun forModule (module : String? ): RustWriter = if (module == null ) {
454
455
RustWriter (" lib.rs" , " crate" )
455
456
} else {
456
- RustWriter (" $module .rs" , " crate::$module " )
457
+ var writer = RustWriter (" $module .rs" , " crate::$module " )
458
+ RenderSerdeAttribute .importSerde(writer)
459
+ writer
457
460
}
458
461
459
462
fun factory (debugMode : Boolean ): Factory <RustWriter > = Factory { fileName: String , namespace: String ->
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import software.amazon.smithy.model.shapes.MemberShape
10
10
import software.amazon.smithy.model.shapes.StructureShape
11
11
import software.amazon.smithy.rust.codegen.core.rustlang.Attribute
12
12
import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter
13
+ import software.amazon.smithy.rust.codegen.core.rustlang.raw
13
14
import software.amazon.smithy.rust.codegen.core.util.isEventStream
14
15
import software.amazon.smithy.rust.codegen.core.util.isStreaming
15
16
@@ -30,6 +31,13 @@ public object RenderSerdeAttribute {
30
31
}
31
32
}
32
33
34
+ public fun importSerde (writer : RustWriter ) {
35
+ // we need this for skip serde to work
36
+ Attribute .AllowUnusedImports .render(writer)
37
+ Attribute (" " ).SerdeSerializeOrDeserialize ().render(writer)
38
+ writer.raw(" use serde;" )
39
+ }
40
+
33
41
public fun writeAttributes (writer : RustWriter ) {
34
42
Attribute (" " ).SerdeSerialize ().render(writer)
35
43
Attribute (" " ).SerdeDeserialize ().render(writer)
You can’t perform that action at this time.
0 commit comments