diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 659f4c605b..ff97dff4e9 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -28,3 +28,21 @@ author = "alonlud" references = ["smithy-rs#1390"] meta = { "breaking" = false, "tada" = true, "bug" = false } author = "Velfi" + +[[smithy-rs]] +message = "Add ability to specify a different rust crate name than the one derived from the package name" +references = ["smithy-rs#1404"] +meta = { "breaking" = false, "tada" = false, "bug" = false } +author = "petrosagg" + +[[smithy-rs]] +message = "Switch to [RustCrypto](https://github.com/RustCrypto)'s implementation of MD5." +references = ["smithy-rs#1404"] +meta = { "breaking" = false, "tada" = false, "bug" = false } +author = "petrosagg" + +[[aws-sdk-rust]] +message = "Switch to [RustCrypto](https://github.com/RustCrypto)'s implementation of MD5." +references = ["smithy-rs#1404"] +meta = { "breaking" = false, "tada" = false, "bug" = false } +author = "petrosagg" diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/CargoDependency.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/CargoDependency.kt index 147d8941fa..43b7e1baee 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/CargoDependency.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/rustlang/CargoDependency.kt @@ -115,8 +115,7 @@ class InlineDependency( } } -fun CargoDependency.asType(): RuntimeType = - RuntimeType(null, dependency = this, namespace = this.name.replace("-", "_")) +fun CargoDependency.asType(): RuntimeType = RuntimeType(null, dependency = this, namespace = rustName) data class Feature(val name: String, val default: Boolean, val deps: List) @@ -128,7 +127,8 @@ data class CargoDependency( private val location: DependencyLocation, val scope: DependencyScope = DependencyScope.Compile, val optional: Boolean = false, - val features: Set = emptySet() + val features: Set = emptySet(), + val rustName: String = name.replace("-", "_") ) : RustDependency(name) { val key: Triple get() = Triple(name, location, scope) @@ -143,7 +143,7 @@ data class CargoDependency( is Local -> "local" } - fun rustName(name: String): RuntimeType = RuntimeType(name, this, this.name.replace("-", "_")) + fun rustName(name: String): RuntimeType = RuntimeType(name, this, this.rustName) fun toMap(): Map { val attribs = mutableMapOf() @@ -199,7 +199,7 @@ data class CargoDependency( val Hyper: CargoDependency = CargoDependency("hyper", CratesIo("0.14")) val HyperWithStream: CargoDependency = Hyper.withFeature("stream") val LazyStatic: CargoDependency = CargoDependency("lazy_static", CratesIo("1.4")) - val Md5: CargoDependency = CargoDependency("md5", CratesIo("0.7")) + val Md5: CargoDependency = CargoDependency("md-5", CratesIo("0.10"), rustName = "md5") val PercentEncoding: CargoDependency = CargoDependency("percent-encoding", CratesIo("2")) val PrettyAssertions: CargoDependency = CargoDependency("pretty_assertions", CratesIo("1"), scope = DependencyScope.Dev) val Regex: CargoDependency = CargoDependency("regex", CratesIo("1")) diff --git a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/HttpChecksumRequiredGenerator.kt b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/HttpChecksumRequiredGenerator.kt index 72bbbbc9f1..5790d16023 100644 --- a/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/HttpChecksumRequiredGenerator.kt +++ b/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/customizations/HttpChecksumRequiredGenerator.kt @@ -42,7 +42,7 @@ class HttpChecksumRequiredGenerator( .body() .bytes() .expect("checksum can only be computed for non-streaming operations"); - let checksum = #{md5}::compute(data); + let checksum = <#{md5}::Md5 as #{md5}::Digest>::digest(data); req.headers_mut().insert( #{http}::header::HeaderName::from_static("content-md5"), #{base64_encode}(&checksum[..]).parse().expect("checksum is valid header value")