8000 Wrap the `Upload` buffer with an AsyncRead cursor (fix #1263) by xamgore · Pull Request #1718 · async-graphql/async-graphql · GitHub
[go: up one dir, main page]

Skip to content

Wrap the Upload buffer with an AsyncRead cursor (fix #1263) #1718

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xamgore
Copy link
Contributor
@xamgore xamgore commented May 25, 2025

This crate when being compiled with:

  • unblock feature on
  • tempfile feature off

Gets an error message:

std::io::Cursor::new(self.content)
the trait AsyncRead is not implemented for std::io::Cursor<bytes::Bytes>

Lucky us, futures_util has a wrapper type just for that.

/// Convert to a `AsyncRead`.
#[cfg(feature = "unblock")]
#[cfg_attr(docsrs, doc(cfg(feature = "unblock")))]
pub fn into_async_read(self) -> impl AsyncRead + Sync + Send + 'static {
    #[cfg(feature = "tempfile")]
    {
        blocking::Unblock::new(self.content)
    }

    #[cfg(not(feature = "tempfile"))]
    {
        futures_util::io::Cursor::new(self.content)
    }
}

It returns futures_io::if_std::AsyncRead. The trait is implemented for the futures_util::io::Cursor.

…1263)

This crate when being compiled with:
- `unblock` feature on
- `tempfile` feature off

Gets an error message:
> std::io::Cursor::new(self.content)
> the trait `AsyncRead` is not implemented for `std::io::Cursor<bytes::Bytes>`

Lucky us, `futures_util` has a wrapper type just for that.
@xamgore xamgore changed the title Wrap the Upload buffer with an AsyncRead cursor (fix #1263) WIP: Wrap the Upload buffer with an AsyncRead cursor (fix #1263) May 25, 2025
@xamgore xamgore closed this May 25, 2025
@xamgore xamgore reopened this May 26, 2025
@xamgore xamgore changed the title WIP: Wrap the Upload buffer with an AsyncRead cursor (fix #1263) Wrap the Upload buffer with an AsyncRead cursor (fix #1263) May 26, 2025
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.

1 participant
0