-
Notifications
You must be signed in to change notification settings - Fork 213
RFC30 #2615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thomas-k-cameron
wants to merge
439
commits into
smithy-lang:main
Choose a base branch
from
thomas-k-cameron:RFC30/kotlin-codegen-core
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
RFC30 #2615
Changes from all commits
Commits
Show all changes
439 commits
Select commit
Hold shift + click to select a range
bf2cf28
Merge commit '234b2e4c83cfe8c347ef7d4e6dd9381b7837cbc9' into RFC30/do…
thomas-k-cameron c216199
document
thomas-k-cameron 9aba861
update
thomas-k-cameron c209b13
update
thomas-k-cameron 6f220f4
Merge commit 'e1cf72e52d152519f57a66d95a23322fe1de0759' into RFC30/Blob
thomas-k-cameron e2f92de
pre-commit
thomas-k-cameron 23df5a8
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron d07e664
Merge branch 'main' into RFC30/Blob
thomas-k-cameron afd64a9
FIX
thomas-k-cameron be7dbbb
Merge branch 'main' into RFC30/Blob
thomas-k-cameron be405e4
updater
thomas-k-cameron 6298c76
Merge branch 'main' into RFC30/compiletime-benchmark-to-ci
thomas-k-cameron 6d1f1de
Update ci.yml
thomas-k-cameron ba93ad7
Merge branch 'main' into RFC30/Blob
thomas-k-cameron ff729b5
Merge branch 'main' into RFC30/Blob
thomas-k-cameron fe9cfa9
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 808c645
Merge branch 'main' into RFC30/Blob
thomas-k-cameron 50ad110
Shorten doc comment
jdisanti 4e31189
Merge branch 'main' into RFC30/number
jdisanti e387795
add ciborium
thomas-k-cameron 37bea69
add ciborium
thomas-k-cameron ff47d3e
update
thomas-k-cameron dab61c0
Merge branch 'main' into RFC30/Blob
thomas-k-cameron 5fbd4cf
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron d8d5169
update
thomas-k-cameron cc92bba
update
thomas-k-cameron 0874bbd
fix
thomas-k-cameron abcaa83
update
thomas-k-cameron ffe2713
fix
thomas-k-cameron cb0a64a
update
thomas-k-cameron 32eb725
Merge branch 'main' into RFC30/date_time
thomas-k-cameron ab1eef5
lint fix
thomas-k-cameron db368bc
Merge branch 'RFC30/date_time' of https://github.com/thomas-k-cameron…
thomas-k-cameron d9f362b
FIX docs
thomas-k-cameron fe1cbce
FIX
thomas-k-cameron 06a3cba
Merge branch 'main' into RFC30/serde-decorator
thomas-k-cameron c9a4ae0
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron 893692a
Update FluentClientGenerator.kt
thomas-k-cameron c2cce08
update
thomas-k-cameron 48c04f8
update
thomas-k-cameron bbd94ba
update
thomas-k-cameron 5a8f9d3
Merge branch 'main' into RFC30/date_time
thomas-k-cameron 75e84e7
Update FluentClientGenerator.kt
thomas-k-cameron 2b1a69f
update
thomas-k-cameron 7115727
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron 792e0e9
update
thomas-k-cameron 4dfd9fb
Delete serde_impl_check.rs
thomas-k-cameron 9f2e9c3
Delete Cargo.toml
thomas-k-cameron 98dcb33
Delete deser.rs
thomas-k-cameron 3610a39
Delete ser.rs
thomas-k-cameron a0655b2
Update lib.rs
thomas-k-cameron 62e295c
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 3650242
update
thomas-k-cameron ad6acba
update
thomas-k-cameron 47593d4
update
thomas-k-cameron 84e5758
update
thomas-k-cameron 446d2ef
fix
thomas-k-cameron 04f294e
update
thomas-k-cameron 535cb68
fix
thomas-k-cameron c047c6e
FIX
thomas-k-cameron 739d2c8
update
thomas-k-cameron 72f15cd
update
thomas-k-cameron ad8f413
update fluent client
thomas-k-cameron e2b77cb
Merge branch 'main' into RFC30/date_time
thomas-k-cameron d1069dc
fix
thomas-k-cameron 2cb1e9b
update
thomas-k-cameron 663dff3
update
thomas-k-cameron 8b38afc
update
thomas-k-cameron 525f572
update
thomas-k-cameron e3367dd
update
thomas-k-cameron f5f1f4e
FIX
thomas-k-cameron ec9432a
update
thomas-k-cameron dc21f19
update
thomas-k-cameron 5972800
update
thomas-k-cameron 54a187b
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron e850ea2
update
thomas-k-cameron 8b2877e
update
thomas-k-cameron 4be97c3
update
thomas-k-cameron ca47afe
change input path
thomas-k-cameron 3bd1a7b
update
thomas-k-cameron a0a4651
update
thomas-k-cameron 299e5ec
FIX
thomas-k-cameron 605689e
updater
thomas-k-cameron ef38bbd
Merge branch 'main' into RFC30/add-set-fields
thomas-k-cameron 857f3d4
FIX
thomas-k-cameron 7bd1365
asdf
thomas-k-cameron e5cd52f
update
thomas-k-cameron a4bbee1
Merge branch 'main' into RFC30/date_time
thomas-k-cameron 9006b71
Merge branch 'main' into RFC30/compiletime-benchmark-to-ci
thomas-k-cameron 929ff0d
update
thomas-k-cameron e1c1b40
fix
thomas-k-cameron 2eb7c42
update
thomas-k-cameron 5639356
precommit
thomas-k-cameron b97a85c
update
thomas-k-cameron 34eaadb
update
thomas-k-cameron 09672b0
update
thomas-k-cameron 5de9d85
Merge branch 'main' into RFC30/compiletime-benchmark-to-ci
thomas-k-cameron 3d47d56
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron e292f6d
Merge commit '4e31189d7043317c4454e0dcbbaeddddb11b920f' into RFC30/ko…
thomas-k-cameron a14c34c
Merge commit 'ffe271363f042ba52e43081f55f0862eca8770fd' into RFC30/ko…
thomas-k-cameron 394de16
Merge commit '06a3cba6f146576a9f8a43e1b62fa020ca04aaed' into RFC30/ko…
thomas-k-cameron 1ef454a
update
thomas-k-cameron 71fb1fe
Merge commit '5de9d8512173b7d986a82e5ed2dc10b927561da7' into RFC30/ko…
thomas-k-cameron 05fa5b5
Merge commit 'b97a85c841fad4a08ffbfa66c5c75dc33276f3cf' into RFC30/ko…
thomas-k-cameron e7758fd
Merge commit 'c216199245119b272bd2bca7071d5109e026b255' into RFC30/ko…
thomas-k-cameron 9570c53
pre-commit
thomas-k-cameron 5f0ad1b
fix
thomas-k-cameron 1fb6910
update
thomas-k-cameron 76fe11d
fix
thomas-k-cameron c4ab823
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron c12c360
Merge branch 'RFC30/kotlin-codegen-core' of https://github.com/thomas…
thomas-k-cameron 2efda16
update
thomas-k-cameron 7787563
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 6e38a83
Merge branch 'main' into RFC30/serde-decorator
thomas-k-cameron 495ad68
Merge branch 'main' into RFC30/serde-decorator
thomas-k-cameron b15f93a
fix
thomas-k-cameron 388ee18
asdf
thomas-k-cameron 9ae6c0f
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 55daa77
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 3a998e5
fix
thomas-k-cameron fc65623
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron ad4ac09
asdf
thomas-k-cameron e019369
fix
thomas-k-cameron 4f65d8d
add
thomas-k-cameron efc0e20
Merge branch 'main' into RFC30/tests
thomas-k-cameron 8565bf2
test
thomas-k-cameron f578b86
Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codeg…
thomas-k-cameron 268b876
Merge branch 'main' into RFC30/test2
thomas-k-cameron a3e8546
Update codegen-client/src/main/kotlin/software/amazon/smithy/rust/cod…
thomas-k-cameron d614f5f
Rust.kt
thomas-k-cameron 31c16bd
Merge branch 'RFC30/test2' of https://github.com/thomas-k-cameron/smi…
thomas-k-cameron 0df1dfb
Merge branch 'main' into RFC30/test2
thomas-k-cameron e6512fb
asdf
thomas-k-cameron 3624b37
pre-commit
thomas-k-cameron e0311c3
check
thomas-k-cameron 6e87b13
Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codeg…
thomas-k-cameron 2f25042
Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codeg…
thomas-k-cameron b0c4133
Apply suggestions from code review
thomas-k-cameron 2284425
Merge branch 'main' into RFC30/tests
thomas-k-cameron 7e06e0c
FIX
thomas-k-cameron 1acf514
Merge branch 'main' into RFC30/test2
thomas-k-cameron 84c943d
fix
thomas-k-cameron 7f9329d
Merge branch 'main' into RFC30/tests
thomas-k-cameron c2abf69
fix
thomas-k-cameron c358294
fix
thomas-k-cameron 99113b5
enable by default
thomas-k-cameron 1e4ec95
Merge branch 'main' into RFC30/test2
thomas-k-cameron 5a36064
fix
thomas-k-cameron 2b24f9d
Merge branch 'RFC30/test2' of https://github.com/thomas-k-cameron/smi…
thomas-k-cameron 149711f
Merge branch 'main' into RFC30/tests
thomas-k-cameron a90147f
update
thomas-k-cameron 79a2957
squash
thomas-k-cameron f02b3e7
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 75c091d
add compilation guard
thomas-k-cameron 71cfdf7
update
thomas-k-cameron 7f8162d
update
thomas-k-cameron ad001ca
refactoring
thomas-k-cameron c49b208
update
thomas-k-cameron 1c24991
update
thomas-k-cameron 5b5f201
update
thomas-k-cameron 81f7efd
update
thomas-k-cameron e6dbd97
update
thomas-k-cameron 9e997b6
update
thomas-k-cameron 6f35925
Rfc30/compiletime benchmark to ci (#22)
thomas-k-cameron 970d4c2
Update Rust.kt
thomas-k-cameron cc33514
Update Rust.kt
thomas-k-cameron 8d78bd4
fix
thomas-k-cameron 7d80faf
better docs
thomas-k-cameron 5756a41
update
thomas-k-cameron 01a69fc
Merge branch 'main' into RFC30/test2
thomas-k-cameron 0dca49e
Merge branches 'RFC30/test2' and 'RFC30/test2' of https://github.com/…
thomas-k-cameron 1496901
fix
thomas-k-cameron 73b40a4
fix
thomas-k-cameron 2647de9
update
thomas-k-cameron 16b51e3
Merge branch 'main' into RFC30/test2
thomas-k-cameron ef778af
Update SerdeDecorator.kt
thomas-k-cameron 83cc5b5
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 0d5a831
Merge commit 'ef778af0e7023bf7cdcfb77154226496b84e8f0d' into RFC30/ko…
thomas-k-cameron 220fd4c
Merge commit '16b51e3b74b19ff2df7c087efe56a2f5190781b1' into RFC30/ko…
thomas-k-cameron d236687
Merge commit 'c2abf697f666619d454d5994b53ae83841526125' into RFC30/ko…
thomas-k-cameron 0b80fff
fix
thomas-k-cameron 770da16
modified: aws/sdk-codegen/src/main/kotlin/software/amazon/s…
thomas-k-cameron bc1c05c
asdf
thomas-k-cameron 8becf06
fix
thomas-k-cameron 2b91272
asdf
thomas-k-cameron 40a3322
fix
thomas-k-cameron b07a3bc
asdf
thomas-k-cameron 7b0a825
asdf
thomas-k-cameron 535127e
update
thomas-k-cameron 7882c7f
asdf
thomas-k-cameron 0e5156f
Merge branch 'main' into RFC30/blob-fixing
thomas-k-cameron c998094
Update check-aws-sdk-smoketest-docs-clippy-udeps
thomas-k-cameron 210b9c8
asdf
thomas-k-cameron 77bd0de
Update CodegenDelegator.kt
thomas-k-cameron 92cd3f8
Update LibRsGenerator.kt
thomas-k-cameron bbb321e
asdf
thomas-k-cameron fa8c04b
asdf
thomas-k-cameron 918f2cd
Update LibRsGenerator.kt
thomas-k-cameron 8802e83
Update SerdeDecorator.kt
thomas-k-cameron 5211559
asdf
thomas-k-cameron 88c14cb
Merge branch 'main' into RFC30/serde-decorator
thomas-k-cameron c4a41c2
update
thomas-k-cameron dd4a511
asdf
thomas-k-cameron 982a95d
Delete devcontainer.json
thomas-k-cameron 954b7e9
Merge branch 'main' into RFC30/serde-decorator
thomas-k-cameron d83fdb7
Merge commit '0e5156f67e0128f6714af2b6cb956a1855fb786e' into RFC30/ko…
thomas-k-cameron 27b667a
Merge commit '210b9c855bcf25c38c9bbecc6da8ab36e9eb7b4a' into RFC30/ko…
thomas-k-cameron 6a4afe8
Merge commit '954b7e9168128dae84490a431fe85928aea19dad' into RFC30/ko…
thomas-k-cameron fd17883
Merge commit '149711f978d1ba6a4311042907622b20d27f66a7' into RFC30/ko…
thomas-k-cameron b08e2ca
Merge commit 'd2690e7ab19c1ca98124ec1d5870ebfe25613879' into RFC30/ko…
thomas-k-cameron c969377
fix
thomas-k-cameron c12f3d4
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 7974c27
ok
thomas-k-cameron 4d65b27
ok
thomas-k-cameron 7cbd610
ok
thomas-k-cameron db5fc49
ok
thomas-k-cameron 5ce4723
ok
thomas-k-cameron 5345cd0
RUSTFLAG*S*
thomas-k-cameron 1560c76
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron e4157d3
Update CodegenTestCommon.kt
thomas-k-cameron 6d00795
test
thomas-k-cameron fb9892f
ok
thomas-k-cameron ad0def0
Merge branch 'RFC30/kotlin-codegen-core' of https://github.com/thomas…
thomas-k-cameron 6b08178
Update ci.yml
thomas-k-cameron e280f62
Update ci.yml
thomas-k-cameron 14040cb
revert
thomas-k-cameron 316010e
remove export RUSTFLAGS="--cfg aws_sdk_unstable"
thomas-k-cameron b64f46a
Merge branch 'RFC30/kotlin-codegen-core' of https://github.com/thomas…
thomas-k-cameron c948f8d
# modified: .github/workflows/ci.yml
thomas-k-cameron 334f428
asdf
thomas-k-cameron 43f1677
asdf
thomas-k-cameron 4ab1f9c
asdf
thomas-k-cameron c91a155
asdf
thomas-k-cameron 270fe2f
Merge branch 'awslabs:main' into RFC30/kotlin-codegen-core
thomas-k-cameron 53e37ca
asdf
thomas-k-cameron e6947c4
asdf
thomas-k-cameron ccc966d
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 9526ff7
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron dca47db
update
thomas-k-cameron 651af86
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 312a853
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron 077c611
update
thomas-k-cameron 8350a45
update
thomas-k-cameron 2ba9b75
modified: codegen-client/src/main/kotlin/software/amazon/smithy/rus…
thomas-k-cameron 8f386af
modified: codegen-core/src/main/kotlin/software/amazon/smithy/rust/…
thomas-k-cameron 6508d8b
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron ed9f046
merge
thomas-k-cameron a57a62d
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron a081c6d
modified: codegen-client/src/main/kotlin/software/amazon/smithy/rus…
1e9b021
Merge branch 'main' into RFC30/kotlin-codegen-core
thomas-k-cameron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/SerdeDecorator.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.client.smithy.customize | ||
|
||
import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext | ||
import software.amazon.smithy.rust.codegen.core.rustlang.containerDocs | ||
import software.amazon.smithy.rust.codegen.core.rustlang.Feature | ||
import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter | ||
import software.amazon.smithy.rust.codegen.core.rustlang.Writable | ||
import software.amazon.smithy.rust.codegen.core.rustlang.writable | ||
import software.amazon.smithy.rust.codegen.core.smithy.RustCrate | ||
import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization | ||
import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection | ||
import software.amazon.smithy.rust.codegen.core.smithy.generators.ModuleDocSection | ||
|
||
/** | ||
* Decorator that adds the `serde-serialize` and `serde-deserialize` features. | ||
*/ | ||
class SerdeDecorator : ClientCodegenDecorator { | ||
override val name: String = "SerdeDecorator" | ||
override val order: Byte = 5 | ||
|
||
override fun extras(codegenContext: ClientCodegenContext, rustCrate: RustCrate) { | ||
fun feature(featureName: String): Feature { | ||
return Feature(featureName, false, listOf("aws-smithy-types/$featureName")) | ||
} | ||
rustCrate.mergeFeature(feature("serde-serialize")) | ||
rustCrate.mergeFeature(feature("serde-deserialize")) | ||
|
||
} | ||
|
||
override fun libRsCustomizations( | ||
codegenContext: ClientCodegenContext, | ||
baseCustomizations: List<LibRsCustomization> | ||
): List<LibRsCustomization> { | ||
return baseCustomizations + SerdeDocGenerator(codegenContext) | ||
} | ||
} | ||
|
||
class SerdeDocGenerator(private val codegenContext: ClientCodegenContext) : LibRsCustomization() { | ||
override fun section(section: LibRsSection): Writable { | ||
return when (section) { | ||
is LibRsSection.ModuleDoc-> | ||
if (section.subsection is ModuleDocSection.AWSSdkUnstable) { | ||
serdeInfoText() | ||
} else { | ||
emptySection | ||
} | ||
|
||
else -> emptySection | ||
} | ||
} | ||
|
||
private fun serdeInfoText(): Writable { | ||
return writable { | ||
containerDocs( | ||
""" | ||
## How to enable `Serialize` and `Deserialize` | ||
|
||
This data type implements `Serialize` and `Deserialize` traits from the popular serde crate, but those traits are behind feature gate. | ||
|
||
As they increase it's compile time dramatically, you should not turn them on unless it's necessary. | ||
Implementation of `serde` traits in AWS SDK for Rust is still unstable, and implementation may change anytime in future. | ||
|
||
To enable traits, you must pass `aws_sdk_unstable` to RUSTFLAGS and enable `serde-serialize` or `serde-deserialize` feature. | ||
|
||
e.g. | ||
```bash,no_run | ||
export RUSTFLAGS="--cfg aws_sdk_unstable" | ||
cargo build --features serde-serialize serde-deserialize | ||
``` | ||
|
||
If you enable `serde-serialize` and/or `serde-deserialize` without `RUSTFLAGS="--cfg aws_sdk_unstable"`, | ||
compilation will fail with warning. | ||
|
||
""".trimIndent() | ||
) | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/RenderSerdeAttribute.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.core.smithy.generators | ||
|
||
import software.amazon.smithy.model.Model | ||
import software.amazon.smithy.model.shapes.MemberShape | ||
import software.amazon.smithy.model.shapes.Shape | ||
import software.amazon.smithy.model.traits.ErrorTrait | ||
import software.amazon.smithy.model.traits.SensitiveTrait | ||
import software.amazon.smithy.rust.codegen.core.rustlang.Attribute | ||
import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter | ||
import software.amazon.smithy.rust.codegen.core.rustlang.raw | ||
import software.amazon.smithy.rust.codegen.core.util.hasTrait | ||
import software.amazon.smithy.rust.codegen.core.util.isEventStream | ||
import software.amazon.smithy.rust.codegen.core.util.isStreaming | ||
|
||
// Part of RFC30 | ||
public object RenderSerdeAttribute { | ||
private const val warningMessage = "/// This data may contain sensitive information; It will not be obscured when serialized.\n" | ||
private const val skipFieldMessage = "/// This field will note be serialized or deserialized because it's a stream type.\n" | ||
|
||
// guards to check if you want to add serde attributes | ||
fun isApplicable(shape: Shape, model: Model): Boolean { | ||
return !shape.hasTrait<ErrorTrait>() && shape.members().none { it.isEventStream(model) } | ||
} | ||
|
||
public fun addSensitiveWarningDoc(writer: RustWriter, shape: Shape, model: Model) { | ||
if (isApplicable(shape, model) && shape.hasTrait<SensitiveTrait>()) { | ||
writer.writeInline(warningMessage) | ||
} | ||
} | ||
|
||
public fun addSerdeWithoutShapeModel(writer: RustWriter) { | ||
Attribute("").SerdeSerialize().render(writer) | ||
Attribute("").SerdeDeserialize().render(writer) | ||
} | ||
|
||
public fun addSerde(writer: RustWriter, shape: Shape, model: Model) { | ||
if (isApplicable(shape, model)) { | ||
addSerdeWithoutShapeModel(writer) | ||
} | ||
} | ||
|
||
public fun skipIfStream(writer: RustWriter, member: MemberShape, model: Model, shape: Shape) { | ||
if (isApplicable(shape, model) && member.isStreaming(model)) { | ||
writer.writeInline(skipFieldMessage) | ||
Attribute("").serdeSkip().render(writer) | ||
} | ||
} | ||
|
||
public fun importSerde(writer: RustWriter, shape: Shape, model: Model) { | ||
if (isApplicable(shape, model)) { | ||
// we need this for skip serde to work | ||
Attribute.AllowUnusedImports.render(writer) | ||
Attribute("").SerdeSerializeOrDeserialize().render(writer) | ||
writer.raw("use serde;") | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.