drogue-iot / reqwless

Rust async HTTP client for embedded/no_std
Apache License 2.0
129 stars 18 forks source link

Support embedded-nal-async 0.5.0 #38

Closed avlec closed 1 year ago

avlec commented 1 year ago

Update to support a more recent release of embedded-nal-async. I noticed this when trying to use this with this project https://github.com/embassy-rs/embassy which uses the newer version and there seems to be trait incompatibilities I noticed when trying to use TcpClient and DnsSocket from that project.

error[E0277]: the trait bound `TcpClient<'_, embassy_net_driver_channel::Device<'_, 1514>, 4>: embedded_nal_async::stack::tcp::TcpConnect` is not satisfied
   --> src/main.rs:129:56
    |
129 |         let client = reqwless::client::HttpClient::new(&tcp, &dns);
    |                      --------------------------------- ^^^^ the trait `embedded_nal_async::stack::tcp::TcpConnect` is not implemented for `TcpClient<'_, embassy_net_driver_channel::Device<'_, 1514>, 4>`
    |                      |
    |                      required by a bound introduced by this call
    |
help: trait impl with same name found
   --> /home/avlec/rp2040/embassy/embassy-net/src/tcp.rs:469:5
    |
469 | /     impl<'d, D: Driver, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_nal_async::TcpConnect
470 | |         for TcpClient<'d, D, N, TX_SZ, RX_SZ>
    | |_____________________________________________^
    = note: perhaps two different versions of crate `embedded_nal_async` are being used?
    = help: the trait `embedded_nal_async::stack::tcp::TcpConnect` is implemented for `&T`
note: required by a bound in `HttpClient::<'a, T, D>::new`
   --> /home/avlec/rp2040/reqwless/src/client.rs:58:8
    |
58  |     T: TcpConnect + 'a,
    |        ^^^^^^^^^^ required by this bound in `HttpClient::<'a, T, D>::new`
...
62  |     pub fn new(client: &'a T, dns: &'a D) -> Self {
    |            --- required by a bound in this associated function

error[E0277]: the trait bound `DnsSocket<'_, embassy_net_driver_channel::Device<'_, 1514>>: embedded_nal_async::dns::Dns` is not satisfied
   --> src/main.rs:129:62
    |
129 |         let client = reqwless::client::HttpClient::new(&tcp, &dns);
    |                      ---------------------------------       ^^^^ the trait `embedded_nal_async::dns::Dns` is not implemented for `DnsSocket<'_, embassy_net_driver_channel::Device<'_, 1514>>`
    |                      |
    |                      required by a bound introduced by this call
    |
help: trait impl with same name found
   --> /home/avlec/rp2040/embassy/embassy-net/src/dns.rs:72:1
    |
72  | impl<'a, D> embedded_nal_async::Dns for DnsSocket<'a, D>
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `embedded_nal_async` are being used?
note: required by a bound in `HttpClient::<'a, T, D>::new`
   --> /home/avlec/rp2040/reqwless/src/client.rs:59:8
    |
59  |     D: Dns + 'a,
    |        ^^^ required by this bound in `HttpClient::<'a, T, D>::new`
...
62  |     pub fn new(client: &'a T, dns: &'a D) -> Self {
    |            --- required by a bound in this associated function

error[E0277]: the trait bound `TcpClient<'_, embassy_net_driver_channel::Device<'_, 1514>, 4>: embedded_nal_async::stack::tcp::TcpConnect` is not satisfied
   --> src/main.rs:129:22
    |
129 |         let client = reqwless::client::HttpClient::new(&tcp, &dns);
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `embedded_nal_async::stack::tcp::TcpConnect` is not implemented for `TcpClient<'_, embassy_net_driver_channel::Device<'_, 1514>, 4>`
    |
help: trait impl with same name found
   --> /home/avlec/rp2040/embassy/embassy-net/src/tcp.rs:469:5
    |
469 | /     impl<'d, D: Driver, const N: usize, const TX_SZ: usize, const RX_SZ: usize> embedded_nal_async::TcpConnect
470 | |         for TcpClient<'d, D, N, TX_SZ, RX_SZ>
    | |_____________________________________________^
    = note: perhaps two different versions of crate `embedded_nal_async` are being used?
    = help: the trait `embedded_nal_async::stack::tcp::TcpConnect` is implemented for `&T`
note: required by a bound in `HttpClient`
   --> /home/avlec/rp2040/reqwless/src/client.rs:17:8
    |
15  | pub struct HttpClient<'a, T, D>
    |            ---------- required by a bound in this struct
16  | where
17  |     T: TcpConnect + 'a,
    |        ^^^^^^^^^^ required by this bound in `HttpClient`

error[E0277]: the trait bound `DnsSocket<'_, embassy_net_driver_channel::Device<'_, 1514>>: embedded_nal_async::dns::Dns` is not satisfied
   --> src/main.rs:129:22
    |
129 |         let client = reqwless::client::HttpClient::new(&tcp, &dns);
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `embedded_nal_async::dns::Dns` is not implemented for `DnsSocket<'_, embassy_net_driver_channel::Device<'_, 1514>>`
    |
help: trait impl with same name found
   --> /home/avlec/rp2040/embassy/embassy-net/src/dns.rs:72:1
    |
72  | impl<'a, D> embedded_nal_async::Dns for DnsSocket<'a, D>
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `embedded_nal_async` are being used?
note: required by a bound in `HttpClient`
   --> /home/avlec/rp2040/reqwless/src/client.rs:18:8
    |
15  | pub struct HttpClient<'a, T, D>
    |            ---------- required by a bound in this struct
...
18  |     D: Dns + 'a,
    |        ^^^ required by this bound in `HttpClient`

Edit: Just confirmed by rolling back the project referenced above to a commit from two weeks ago that uses the same embedded_nal_async (adding the feature unstable-traits to their embassy-net crate) it at least builds

bugadani commented 1 year ago

I believe this issue can now be closed.