Closed MarcelCoding closed 2 years ago
Ok, first of all, thanks for your fast response. I looked a bit further into it and noticed that theoretically, the function exists but because of some trait bounds, I can't use it:
error[E0599]: the method `send` exists for struct `SplitStream<WebSocketStream<tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>>>`, but its trait bounds were not satisfied
--> zia-client\src\upstream\ws.rs:45:12
|
45 | wo.send(Message::binary(buf)).await.unwrap();
| ^^^^ method cannot be called on `SplitStream<WebSocketStream<tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>>>` due to unsatisfied trait bounds
|
::: C:\Users\Marcel\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-util-0.3.21\src\stream\stream\split.rs:14:1
|
14 | pub struct SplitStream<S>(BiLock<S>);
| -------------------------------------
| |
| doesn't satisfy `_: SinkExt<_>`
| doesn't satisfy `_: futures_util::Sink<_>`
|
= note: the following trait bounds were not satisfied:
`SplitStream<WebSocketStream<tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>>>: futures_util::Sink<_>`
which is required by `SplitStream<WebSocketStream<tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>>>: SinkExt<_>`
I especially don't understand this part:
= note: the following trait bounds were not satisfied:
`SplitStream<WebSocketStream<tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>>>: futures_util::Sink<_>`
which is required by `SplitStream<WebSocketStream<tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>>>: SinkExt<_>`
If something is implementing Sink then it also automatically should be implementing SinkExt? Or may I am wonge here? I relay don't get it.
Could it be that I am missing some features from some dependencies for that to work as expected?
Yeah right, but you should use SplitSink
, not the SplitStream
. SplitStream
is the reading part 😉
Ohhhh...., thank you. Now it is working. Sorry, I just copied it from Tokyo (where the reading parts come first) and didn't check the types.
Hi, I want to send and receive it independently. Therefore I need to split the connection. Unfortunately, the methods
send
andnext
are no longer available after the split. Is there anything similar that I could use or is this just a missing feature?