thruster-rs / thruster-socketio

A socket.io implementation over thruster
14 stars 2 forks source link

Can‘t compile the example code: chat.rs #7

Closed rts-gordon closed 3 years ago

rts-gordon commented 3 years ago

Hi @trezm , My project will use socketio component, I found the crate thruster-socketio. But there are some errors when I compile the example code: "thruster-socketio/socketio_middleware/examples/chat.rs". Would you like to give me a hand? Thank you very much.

PS C:\job\5research\rust\socketio> cargo build
    Updating crates.io index
   Compiling thruster-socketio v0.1.7
error[E0277]: `T` cannot be sent between threads safely
  --> C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-socketio-0.1.7\src\socketio_context.rs:24:29
   |
24 | impl<T> SocketIOContext for TypedHyperContext<T> {
   |                             ^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely
   | 
  ::: C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-1.1.3\src\context\typed_hyper_context.rs:33:43
   |
33 | pub struct TypedHyperContext<S: 'static + Send + Sync> {
   |                                           ---- required by this bound in `TypedHyperContext`
   |
help: consider restricting type parameter `T`
   |
24 | impl<T: std::marker::Send> SocketIOContext for TypedHyperContext<T> {
   |       ^^^^^^^^^^^^^^^^^^^

error[E0277]: `T` cannot be shared between threads safely
  --> C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-socketio-0.1.7\src\socketio_context.rs:24:29
   |
24 | impl<T> SocketIOContext for TypedHyperContext<T> {
   |                             ^^^^^^^^^^^^^^^^^^^^ `T` cannot be shared between threads safely
   | 
  ::: C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-1.1.3\src\context\typed_hyper_context.rs:33:50
   |
33 | pub struct TypedHyperContext<S: 'static + Send + Sync> {
   |                                                  ---- required by this bound in `TypedHyperContext`
   |
help: consider restricting type parameter `T`
   |
24 | impl<T: Sync> SocketIOContext for TypedHyperContext<T> {
   |       ^^^^^^

error[E0277]: `T` cannot be sent between threads safely
  --> C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-socketio-0.1.7\src\socketio_context.rs:25:21
   |
25 |     fn into_request(self) -> Request<Body> {
   |                     ^^^^ `T` cannot be sent between threads safely
   | 
  ::: C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-1.1.3\src\context\typed_hyper_context.rs:33:43
   |
33 | pub struct TypedHyperContext<S: 'static + Send + Sync> {
   |                                           ---- required by this bound in `TypedHyperContext`
   |
help: consider restricting type parameter `T`
   |
24 | impl<T: std::marker::Send> SocketIOContext for TypedHyperContext<T> {
   |       ^^^^^^^^^^^^^^^^^^^

error[E0277]: `T` cannot be shared between threads safely
  --> C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-socketio-0.1.7\src\socketio_context.rs:25:21
   |
25 |     fn into_request(self) -> Request<Body> {
   |                     ^^^^ `T` cannot be shared between threads safely
   | 
  ::: C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-1.1.3\src\context\typed_hyper_context.rs:33:50
   |
33 | pub struct TypedHyperContext<S: 'static + Send + Sync> {
   |                                                  ---- required by this bound in `TypedHyperContext`
   |
help: consider restricting type parameter `T`
   |
24 | impl<T: Sync> SocketIOContext for TypedHyperContext<T> {
   |       ^^^^^^

error[E0277]: `T` cannot be sent between threads safely
  --> C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-socketio-0.1.7\src\socketio_context.rs:29:15
   |
29 |     fn status(&mut self, code: u32) {
   |               ^^^^^^^^^ `T` cannot be sent between threads safely
   | 
  ::: C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-1.1.3\src\context\typed_hyper_context.rs:33:43
   |
33 | pub struct TypedHyperContext<S: 'static + Send + Sync> {
   |                                           ---- required by this bound in `TypedHyperContext`
   |
help: consider restricting type parameter `T`
   |
24 | impl<T: std::marker::Send> SocketIOContext for TypedHyperContext<T> {
   |       ^^^^^^^^^^^^^^^^^^^

error[E0277]: `T` cannot be shared between threads safely
  --> C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-socketio-0.1.7\src\socketio_context.rs:29:15
   |
29 |     fn status(&mut self, code: u32) {
   |               ^^^^^^^^^ `T` cannot be shared between threads safely
   | 
  ::: C:\Users\Gordon\.cargo\registry\src\github.com-1ecc6299db9ec823\thruster-1.1.3\src\context\typed_hyper_context.rs:33:50
   |
33 | pub struct TypedHyperContext<S: 'static + Send + Sync> {
   |                                                  ---- required by this bound in `TypedHyperContext`
   |
help: consider restricting type parameter `T`
   |
24 | impl<T: Sync> SocketIOContext for TypedHyperContext<T> {
   |       ^^^^^^

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0277`.
error: could not compile `thruster-socketio`

To learn more, run the command again with --verbose.
trezm commented 3 years ago

Looks like this happened because of the increased requirements on Contexts with the most recent version. The code should be updated now to be happy!

rts-gordon commented 3 years ago

Thanks a lot, it can be compiled now. @trezm

I noticed that: module "socketio_proc" has upgrade to 0.1.8, but in module "socketio_middleware" Cargo.toml file, it is still "thruster-socketio-proc = "0.1.6"", is this correct?

trezm commented 3 years ago

Great point, I try to keep the modules in sync, but nothing in the proc module has been updated in a while so we should be fine. I'll be sure to update the dependency in the next release.