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

Update: swap pin-project for pin-project-lite #1503

Merged
merged 8 commits into from
Jun 28, 2022
Merged

Conversation

Velfi
Copy link
Contributor

@Velfi Velfi commented Jun 27, 2022

Motivation and Context

#932

Description

swap pin-project for pin-project-lite

Testing

ran existing tests

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • 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.

@Velfi Velfi changed the title update: swap pin-project for pin-project-lite Update: swap pin-project for pin-project-lite Jun 27, 2022
@Velfi Velfi mentioned this pull request Jun 27, 2022
2 tasks
CHANGELOG.next.toml Outdated Show resolved Hide resolved
///
/// This will yield an `Err(SdkError::ConstructionFailure)` if a message can't be
/// marshalled into an Event Stream frame, (e.g., if the message payload was too large).
pub struct MessageStreamAdapter {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The <T, E> generic args disappeared? Make sure to test this crate with --all-features since the event stream parts aren't on by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, good catch!

Comment on lines 60 to 61
#[pin]
stream: Pin<Box<dyn Stream<Item = Result<T, BoxError>> + Send>>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pin projection actually needed here if the member is Pin? It seems like it shouldn't be, but I'm not 100% sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why it needs to be Pin but if I remove it then the compiler starts complaining about it not implementing some obtuse generic traits.

Copy link
Collaborator

@rcoh rcoh Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdisanti is correct—the key here is using .as_mut() on the stream instead of using pin projection.

Interestingly you actually need to keep pin_project! on the root (or you need to manually implement Unpin (which is safe (!!))

commit if handy: 3e5e4f3

Comment on lines 58 to 59
Once {
#[pin]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do Once and Dyn actually need #[pin]? I understand why Streaming needs it, but I'm fuzzy on why these would need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dyn complains without it but Once seems to be ok when I remove it

pin_project! {
#[project = EnumProj]
pub enum MapRequestFuture<F, E> {
Inner {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really related to your changes, but the name Inner is kind of confusing to me here. Maybe we should have called it Pending or something? Is there a broader idiomatic pattern for this with futures?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at it, I would name the variants Pending and Complete. @rcoh what do you think?

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Comment on lines 60 to 61
#[pin]
stream: Pin<Box<dyn Stream<Item = Result<T, BoxError>> + Send>>,
Copy link
Collaborator

@rcoh rcoh Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdisanti is correct—the key here is using .as_mut() on the stream instead of using pin projection.

Interestingly you actually need to keep pin_project! on the root (or you need to manually implement Unpin (which is safe (!!))

commit if handy: 3e5e4f3

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@Velfi Velfi merged commit 3f10816 into main Jun 28, 2022
@Velfi Velfi deleted the update/use-pin-project-lite branch June 28, 2022 19:01
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

Successfully merging this pull request may close these issues.

3 participants