I’ve been loving rust and hating the futures API. It seems to be an endless trial-and-error-fest and the errors don’t help at all, so it’s mostly trial…
For example, right now I can’t finish one of my projects because of this bizarre error that doesn’t seem to make any sense in my existing knowledge of Rust syntax and the compiler:
error[E0271]: type mismatch resolving `<futures::stream::SplitSink<tokio::codec::Framed<std::boxed::Box<dyn websocket::async::Stream + std::marker::Send>, websocket::async::MessageCodec<websocket::OwnedMessage>>> as futures::Sink>::SinkError == ()` --> src/websocket_client.rs:60:31 | 60 | outgoing_recv.forward(sink); | ^^^^^^^ expected enum `websocket::WebSocketError`, found () | = note: expected type `websocket::WebSocketError` found type `()`
Why is the word
forward the part it’s highlighting here? Where does it expect a websocket error? And where did it find
()? I’ve read the tokio/futures docs site more times than I can count, every time I think I understand combinators, I try and use them to do something seemingly simple and get hit with things like this.
Is there some special magic to reading and understanding these errors? Is this API even meant to be used right now?
The code in question is here:
If I can get this one last bit working with websockets, this project has completely been rewritten in Rust which is great because it’s much easier to dev/maintain/build/test/etc on different operating systems (the C++ one build broke for no apparent reason and wouldn’t fix, hence the rust rewrite…)
The architecture is simple, it’s just a couple of channels one writes to a websocket and the other reads values and places them in a queue which is then polled by the host application’s event loop.
I’d really appreciate some help getting this one over the finishing line, thanks!