aws_sdk_s3/event_receiver.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2/*
3 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7use aws_smithy_http::event_stream::Receiver;
8use aws_smithy_runtime_api::client::result::SdkError;
9use aws_smithy_types::event_stream::RawMessage;
10
11#[derive(Debug)]
12/// Receives unmarshalled events at a time out of an Event Stream.
13pub struct EventReceiver<T, E> {
14 inner: Receiver<T, E>,
15}
16
17impl<T, E> EventReceiver<T, E> {
18 pub(crate) fn new(inner: Receiver<T, E>) -> Self {
19 Self { inner }
20 }
21
22 /// Asynchronously tries to receive an event from the stream. If the stream has ended, it
23 /// returns an `Ok(None)`. If there is a transport layer error, it will return
24 /// `Err(SdkError::DispatchFailure)`. Service-modeled errors will be a part of the returned
25 /// messages.
26 pub async fn recv(&mut self) -> Result<Option<T>, SdkError<E, RawMessage>> {
27 self.inner.recv().await
28 }
29}