-
Notifications
You must be signed in to change notification settings - Fork 197
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
Provide an opt-in in aws-smithy-types-convert
to enable Stream
trait
#2993
Comments
How am I supposed to use
because it is not reexported. Then it becomes a real pain to update any of the packages in a workspace with multiple crates using |
The vast majority of things you need should be re-exported, and it's a bug if they're not (please file something to let us know which type you needed). However, |
Thanks for the detailed feedback!
I think what you're looking for is let config = aws_config::from_env()
.endpoint_url("http://localhost:5001")
.load()
.await;
Yeah, it's not ideal. Most people will never want aws-sdk-config unless they're using https://aws.amazon.com/config/ Not a lot we can do about this unfortunately.
Take a look at |
waiting for smithy-lang/smithy-rs#2993 maybe not worth it yet
Would this be a reasonable way to implement the Stream trait? struct StreamPaginationStream<I> {
inner: PaginationStream<I>,
}
impl<I> StreamPaginationStream<I> {
fn new(inner: PaginationStream<I>) -> Self {
Self { inner }
}
}
impl<I> Stream for StreamPaginationStream<I>
where
Self: Unpin,
{
type Item = I;
fn poll_next(
mut self: Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let fut = self.inner.next();
let fut = pin!(fut);
fut.poll(cx)
}
} (plus an extension trait to create a StreamPaginationStream when doing |
I don't think that will quite work since if your Unfortunately, you would need to create a finite state machine to make it work. |
That makes sense in the general case. I think that given the implementation of |
I couldn't easily figure out how to save the Future, but I was able to use the genawaiter crate which I assume does this internally:
use genawaiter::sync::gen;
use genawaiter::yield_;
...
let mut stream = ...into_paginator().send();
let stream = gen!({
while let Some(output) = stream.next().await {
yield_!(output);
}
});
// stream now implements Stream |
Switched to the more-used async-stream crate: use async_stream::stream;
...
let mut stream = ...into_paginator().send();
let stream = stream!({
while let Some(output) = stream.next().await {
yield output;
}
});
// stream now implements Stream |
Implemented in #3299 |
Context: #2978 (comment)
With
PaginationStream
no longer implementing theStream
trait, we can add a new-type forPaginationStream
to theaws-smithy-types-convert
crate to enable theStream
trait for that new-type.This is an opt-in feature and improves the API ergonomics. Furthermore, when the
Stream
trait goes to 1.0, we can add a new supporting new-type in a backward compatible way.The text was updated successfully, but these errors were encountered: