Unverified Commit c7b3667a authored by Kyle Huey's avatar Kyle Huey Committed by GitHub
Browse files

Add conversions from smithy StatusCode to http StatusCode. (#3637)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
Making this conversion bidirectional is helpful.
<!--- If it fixes an open issue, please link to the issue here -->

## Description
<!--- Describe your changes in detail -->
Add `impl From<StatusCode> for httpN::StatusCode` that does the obvious
thing.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
I'm using these conversions in my own project. As all three crates have
identical constraints on the status code value the changes are trivially
correct.

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

Not clear to me what if anything to do here.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent 1310a3ce
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -28,3 +28,9 @@ message = "Enable aws-smithy-runtime to compile in rustc 1.72.1"
references = ["smithy-rs#3675"]
meta = { "breaking" = false, "tada" = false, "bug" = true, "target" = "client" }
author = "dastrom"

[[aws-smithy-runtime-api]]
message = "Add conversions from smithy StatusCode to http StatusCode."
references = ["smithy-rs#3637"]
meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "all"}
author = "khuey"
+1 −1
Original line number Diff line number Diff line
[package]
name = "aws-smithy-runtime-api"
version = "1.6.2"
version = "1.6.3"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>", "Zelda Hessler <zhessler@amazon.com>"]
description = "Smithy runtime types."
edition = "2021"
+14 −0
Original line number Diff line number Diff line
@@ -57,6 +57,13 @@ impl From<http0::StatusCode> for StatusCode {
    }
}

#[cfg(feature = "http-02x")]
impl From<StatusCode> for http0::StatusCode {
    fn from(value: StatusCode) -> Self {
        Self::from_u16(value.0).unwrap()
    }
}

#[cfg(feature = "http-1x")]
impl From<http1::StatusCode> for StatusCode {
    fn from(value: http1::StatusCode) -> Self {
@@ -64,6 +71,13 @@ impl From<http1::StatusCode> for StatusCode {
    }
}

#[cfg(feature = "http-1x")]
impl From<StatusCode> for http1::StatusCode {
    fn from(value: StatusCode) -> Self {
        Self::from_u16(value.0).unwrap()
    }
}

impl From<StatusCode> for u16 {
    fn from(value: StatusCode) -> Self {
        value.0