-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid exposing
aws_smithy_http::event_stream::receiver::Receiver
in…
… SDK's public API (#3114) ## Motivation and Context Implements #3100 ## Description Currently, we expose `aws_smithy_http::event_stream::Receiver` in generated SDKs, as shown in the following S3's example (see[ a generated diff](https://d2luzm2xt3nokh.cloudfront.net/codegen-diff/cc303ab1a07693ab02d5ec4f06101b628d1dbabe/1aa6a8da7d2b7669ba3ab7179a1fd72aadc03162/aws-sdk-ignore-whitespace/index.html) for `tmp-codegen-diff/aws-sdk/sdk/s3/src/operation/select_object_content/_select_object_content_output.rs`): ``` pub struct SelectObjectContentOutput { <p>The array of results.</p> pub payload: ::aws_smithy_http::event_stream::Receiver< crate::types::SelectObjectContentEventStream, crate::types::error::SelectObjectContentEventStreamError, >, ... ``` This PR wraps `Receiver` in a new-type, called `EventReceiver`, which then supports `pub async fn recv` method whose signature is the same as `aws_smithy_http::event_stream::Receiver::recv`. ## Testing Relied on existing tests (e.g. `s3` and `transcribestreaming` integration tests cover uses cases affected by this change). ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
- Loading branch information
1 parent
c296e8e
commit f9c0526
Showing
13 changed files
with
103 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use aws_smithy_http::event_stream::Receiver; | ||
use aws_smithy_runtime_api::client::result::SdkError; | ||
use aws_smithy_types::event_stream::RawMessage; | ||
|
||
#[derive(Debug)] | ||
/// Receives unmarshalled events at a time out of an Event Stream. | ||
pub struct EventReceiver<T, E> { | ||
inner: Receiver<T, E>, | ||
} | ||
|
||
impl<T, E> EventReceiver<T, E> { | ||
pub(crate) fn new(inner: Receiver<T, E>) -> Self { | ||
Self { inner } | ||
} | ||
|
||
/// Asynchronously tries to receive an event from the stream. If the stream has ended, it | ||
/// returns an `Ok(None)`. If there is a transport layer error, it will return | ||
/// `Err(SdkError::DispatchFailure)`. Service-modeled errors will be a part of the returned | ||
/// messages. | ||
pub async fn recv(&mut self) -> Result<Option<T>, SdkError<E, RawMessage>> { | ||
self.inner.recv().await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters