Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why reimplementing a stream? #3361

Closed
Samrose-Ahmed opened this issue Jan 12, 2024 · 3 comments
Closed

Why reimplementing a stream? #3361

Samrose-Ahmed opened this issue Jan 12, 2024 · 3 comments

Comments

@Samrose-Ahmed
Copy link

Samrose-Ahmed commented Jan 12, 2024

For the PaginationStream.

A Stream is a basic thing in Rust, everyone uses it, theres tons of utilities and code around. It seems you have replaced it with a custom type that resembles a stream but is not actually a Stream. I see #2413 but can we at least provide an opt in compat or something, it makes it very difficult and weird to work with.

@Samrose-Ahmed
Copy link
Author

It seems I can use something like this which is not too bad, but just weird:

pub struct SmithyStreamAdapt<I>(PaginationStream<I>);
impl <I> Stream for SmithyStreamAdapt<I> {
    type Item = I;

    fn poll_next(mut self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Option<Self::Item>> {
        self.0.poll_next(cx)
    }
}

@jdisanti
Copy link
Collaborator

It's a consequence of not being able to make breaking changes to the SDK after the GA launch. Since the Rust Async Working Group is actively working on a stable replacement for the Stream trait, we consider it to be unstable and a risk for future breaking changes. I agree that it's not ideal though. Hopefully we get something in the standard library sooner than later.

In the meantime, we just released a convenience in the aws-smithy-types-convert crate behind the convert-streams feature that allows you to convert our paginators back into streams:

use aws_smithy_types_convert::stream::PaginationStreamExt;

let stream = s3_client.list_objects_v2().bucket("...").into_paginator().send().into_stream_03x();

Thank you, @Ploppz, for the contribution.

@Samrose-Ahmed
Copy link
Author

Ok thanks for the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants