smithy-lang / smithy-rs

Code generation for the AWS SDK for Rust, as well as server and generic smithy client generation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`aws_sdk_eventbridge` does not re-export `HttpResponse`

SAdams601 opened this issue · comments

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.

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

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.

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.

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.

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

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).

Have the same use-case as @klawson88. Would like to create a wrapper around aws-sdk-s3 which requires me to type my wrapper function explicilty asResult<GetObjectOutput, SdkError<GetObjectError, HttpResponse>> which is seemingly not possible without importing aws-smithy-runtime-api