Skip to content
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

Re-export service from root of the generated crate #2010

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata
import software.amazon.smithy.rust.codegen.core.rustlang.RustModule
import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter
import software.amazon.smithy.rust.codegen.core.rustlang.Visibility
import software.amazon.smithy.rust.codegen.core.rustlang.rust
import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext
import software.amazon.smithy.rust.codegen.core.smithy.RustCrate
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport
Expand Down Expand Up @@ -40,6 +41,12 @@ open class ServerServiceGenerator(
* which assigns a symbol location to each shape.
*/
fun render() {
rustCrate.lib {
val serviceName = codegenContext.serviceShape.id.name.toString()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this safe to use as a rust name? i.e, if serviceName was a rust keyword (mod, async, etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also do this in ServerProtocolTestGenerator and ServerServiceGeneratorV2.

IIRC our symbol providers should map shapes in a way which considers reserved keywords, however we've not got a symbol provider which maps ServiceShapes at the moment.

#1724

rust("##[doc(inline, hidden)]")
rust("pub use crate::service::$serviceName;")
}

rustCrate.withModule(RustModule.operation(Visibility.PRIVATE)) {
ServerProtocolTestGenerator(codegenContext, protocolSupport, protocolGenerator).render(this)
}
Expand Down