smithy-lang / smithy-rs

Code generation for the AWS SDK for Rust, as well as server and generic smithy client generation.
Apache License 2.0
467 stars 183 forks source link

`aws_sdk_eventbridge` does not re-export `HttpResponse` #3591

Open SAdams601 opened 2 months ago

SAdams601 commented 2 months ago

aws_sdk_eventbridge::operation::put_events::builders::PutEventsFluentBuilder::send returns a Result<PutEventsOutput, SdkError<PutEventsError, HttpResponse>> but HttpResponse is not available without adding the aws-smithy-runtime-api crate as a dependency.

jdisanti commented 2 months ago

To solve your immediate problem, if you import SdkError from aws_sdk_eventbridge::error::SdkError, it should have the generic already set: https://docs.rs/aws-sdk-eventbridge/latest/aws_sdk_eventbridge/error/type.SdkError.html

SAdams601 commented 2 months ago

I returning the result of the send call from a function so I need to reference the type in the return type of that function.

jdisanti commented 2 months ago

Yes. It's defaulted in the SdkError type that is re-exported in aws-sdk-eventbridge, so you don't actually need to reference it.

klawson88 commented 2 weeks ago

The solution which @jdisanti proposed is fine if one needs to use SdkError in a type annotation, but it does not help when one is looking to construct an instance of the type. My use case, for instance, requires me to do so to produce a fake return value in a test, without the complexity of the recommended solution to mock such a value.

aajtodd commented 1 week ago

SdkError and it's constructor functions are public. You should be able to use them to create an instance.

klawson88 commented 1 week ago

Can that approach be used to construct variants with the raw component (i.e the R type parameter), where that component is the same type used by the SDK (ex. HttpResponse)? It seems like that not is possible without importing aws-smithy-runtime-api, since those raw types are not re-exported by the service-level packages (in my case, it was aws-sdk-s3).