axum-typed-websockets icon indicating copy to clipboard operation
axum-typed-websockets copied to clipboard

chore: bump axum to 0.8

Open morenol opened this issue 11 months ago • 6 comments

morenol avatar Jan 06 '25 16:01 morenol

Does this patch work? I still get a bunch of errors:

error[E0432]: unresolved import `axum::async_trait`
   --> src/lib.rs:115:5
    |
115 |     async_trait,
    |     ^^^^^^^^^^^ no `async_trait` in the root

error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied
   --> src/lib.rs:460:22
    |
460 |     Close(Option<ws::CloseFrame<'static>>),
    |                      ^^^^^^^^^^--------- help: remove the unnecessary generics
    |                      |
    |                      expected 0 lifetime arguments
    |
note: struct defined here, with 0 lifetime parameters
   --> /home/nb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/axum-0.8.1/src/extract/ws.rs:676:12
    |
676 | pub struct CloseFrame {
    |            ^^^^^^^^^^

error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
   --> src/lib.rs:183:23
    |
183 |         let upgrade = FromRequestParts::from_request_parts(parts, state).await?;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
    |
help: use a fully-qualified path to a specific available implementation
    |
183 |         let upgrade = </* self type */ as FromRequestParts>::from_request_parts(parts, state).await?;
    |                       +++++++++++++++++++                 +

error[E0596]: cannot borrow `self.socket` as mutable, as `self` is not declared as mutable
   --> src/lib.rs:282:9
    |
282 |         self.socket.close().await.map_err(Error::Ws)
    |         ^^^^^^^^^^^ cannot borrow as mutable
    |
help: consider changing this to be mutable
    |
278 |     pub async fn close(mut self) -> Result<(), Error<C::Error>>
    |                        +++

error[E0599]: no method named `into_bytes` found for struct `Utf8Bytes` in the current scope
   --> src/lib.rs:313:47
    |
313 |                 ws::Message::Text(msg) => msg.into_bytes(),
    |                                               ^^^^^^^^^^
    |
help: there is a method `bytes` with a similar name
    |
313 |                 ws::Message::Text(msg) => msg.bytes(),
    |                                               ~~~~~

error[E0308]: mismatched types
   --> src/lib.rs:319:62
    |
319 |                     return Poll::Ready(Some(Ok(Message::Ping(buf))));
    |                                                ------------- ^^^- help: try using a conversion method: `.to_vec()`
    |                                                |             |
    |                                                |             expected `Vec<u8>`, found `Bytes`
    |                                                arguments to this enum variant are incorrect
    |
    = note: expected struct `Vec<u8>`
               found struct `axum::body::Bytes`
note: tuple variant defined here
   --> src/lib.rs:454:5
    |
454 |     Ping(Vec<u8>),
    |     ^^^^

error[E0308]: mismatched types
   --> src/lib.rs:322:62
    |
322 |                     return Poll::Ready(Some(Ok(Message::Pong(buf))));
    |                                                ------------- ^^^- help: try using a conversion method: `.to_vec()`
    |                                                |             |
    |                                                |             expected `Vec<u8>`, found `Bytes`
    |                                                arguments to this enum variant are incorrect
    |
    = note: expected struct `Vec<u8>`
               found struct `axum::body::Bytes`
note: tuple variant defined here
   --> src/lib.rs:458:5
    |
458 |     Pong(Vec<u8>),
    |     ^^^^

error[E0308]: `?` operator has incompatible types
   --> src/lib.rs:347:55
    |
347 |             Message::Item(buf) => ws::Message::Binary(C::encode(buf).map_err(Error::Codec)?),
    |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Bytes`, found `Vec<u8>`
    |
    = note: `?` operator cannot convert from `Vec<u8>` to `axum::body::Bytes`
    = note: expected struct `axum::body::Bytes`
               found struct `Vec<u8>`
help: call `Into::into` on this expression to convert `Vec<u8>` into `axum::body::Bytes`
    |
347 |             Message::Item(buf) => ws::Message::Binary(C::encode(buf).map_err(Error::Codec)?.into()),
    |                                                                                            +++++++

error[E0308]: mismatched types
   --> src/lib.rs:348:53
    |
348 |             Message::Ping(buf) => ws::Message::Ping(buf),
    |                                   ----------------- ^^^ expected `Bytes`, found `Vec<u8>`
    |                                   |
    |                                   arguments to this enum variant are incorrect
    |
    = note: expected struct `axum::body::Bytes`
               found struct `Vec<u8>`
note: tuple variant defined here
   --> /home/nb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/axum-0.8.1/src/extract/ws.rs:718:5
    |
718 |     Ping(Bytes),
    |     ^^^^
help: call `Into::into` on this expression to convert `Vec<u8>` into `axum::body::Bytes`
    |
348 |             Message::Ping(buf) => ws::Message::Ping(buf.into()),
    |                                                        +++++++

error[E0308]: mismatched types
   --> src/lib.rs:349:53
    |
349 |             Message::Pong(buf) => ws::Message::Pong(buf),
    |                                   ----------------- ^^^ expected `Bytes`, found `Vec<u8>`
    |                                   |
    |                                   arguments to this enum variant are incorrect
    |
    = note: expected struct `axum::body::Bytes`
               found struct `Vec<u8>`
note: tuple variant defined here
   --> /home/nb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/axum-0.8.1/src/extract/ws.rs:726:5
    |
726 |     Pong(Bytes),
    |     ^^^^
help: call `Into::into` on this expression to convert `Vec<u8>` into `axum::body::Bytes`
    |
349 |             Message::Pong(buf) => ws::Message::Pong(buf.into()),
    |                                                        +++++++

Some errors have detailed explanations: E0107, E0308, E0432, E0596, E0599, E0790.
For more information about an error, try `rustc --explain E0107`.
error: could not compile `axum-typed-websockets` (lib) due to 11 previous errors

NBonaparte avatar Jan 30 '25 07:01 NBonaparte

Does this patch work? I still get a bunch of errors:

Can you try again?

morenol avatar Jan 30 '25 14:01 morenol

Works for me now, thanks!

NBonaparte avatar Jan 31 '25 07:01 NBonaparte

Hi @davidpdrsn. Is there anything we can do to help get this merged upstream?

rakshith-ravi avatar Mar 06 '25 10:03 rakshith-ravi

I've forked this project into https://github.com/cachix/axum-typed-websockets

domenkozar avatar Mar 19 '25 10:03 domenkozar

@davidpdrsn any chance we can get an official release?

rakshith-ravi avatar Sep 25 '25 12:09 rakshith-ravi