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

.reader() + .writer() on ReadWrite #248

Closed
wants to merge 2 commits into from

Conversation

brandonros
Copy link

@brandonros brandonros commented Nov 11, 2023

attempts #247

@@ -500,8 +509,10 @@ impl Drop for Request {
/// Dummy trait that regroups the `Read` and `Write` traits.
///
/// Automatically implemented on all types that implement both `Read` and `Write`.
pub trait ReadWrite: Read + Write {}
impl<T> ReadWrite for T where T: Read + Write {}
Copy link
Author

Choose a reason for hiding this comment

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

i'm 99% sure we don't want to lose this, but it conflicts with existing implementations... not sure how to fix/if this is a code smell?

@brandonros
Copy link
Author

fails with

MacBook-Air:tiny-http brandon 2023-11-11 14:20:04 $ cargo build
   Compiling tiny_http v0.12.0 (/Users/brandon/Desktop/redacted_gui/tiny-http)
error[E0277]: `R` cannot be sent between threads safely
  --> src/util/custom_stream.rs:27:9
   |
27 |         Box::new(self.reader)
   |         ^^^^^^^^^^^^^^^^^^^^^ `R` cannot be sent between threads safely
   |
   = note: required for the cast from `Box<R>` to `Box<(dyn std::io::Read + Send + 'static)>`
help: consider further restricting this bound
   |
23 |     R: Read + std::marker::Send,
   |             +++++++++++++++++++

error[E0277]: `W` cannot be sent between threads safely
  --> src/util/custom_stream.rs:31:9
   |
31 |         Box::new(self.writer)
   |         ^^^^^^^^^^^^^^^^^^^^^ `W` cannot be sent between threads safely
   |
   = note: required for the cast from `Box<W>` to `Box<(dyn std::io::Write + Send + 'static)>`
help: consider further restricting this bound
   |
24 |     W: Write + std::marker::Send,
   |              +++++++++++++++++++

For more information about this error, try `rustc --explain E0277`.
error: could not compile `tiny_http` (lib) due to 2 previous errors

@brandonros
Copy link
Author

flawed design, most likely the only option is to use an event loop like mio or something (and you really shouldn't subject yourself to the pain of trying to do non-async for no good reason)

@brandonros brandonros closed this Nov 11, 2023
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.

None yet

1 participant