Hello !
I'm using websocket crate since the start of my project, like this (see source code here) by using reader and writer in separated threads:
[dependencies]
websocket = "0.24.0"
use websocket::ClientBuilder;
fn main() {
let (mut ws_reader, mut ws_writer) = ClientBuilder::new("ws://echo.websocket.org")
.unwrap()
.connect_insecure()
.unwrap()
.split()
.unwrap();
// use ws_reader in a thread, and ws_writer in an other thread
}
I am now implementing SSL on my server. So I use connect
instead of connect_insecure
, like this:
use websocket::ClientBuilder;
fn main() {
let (mut ws_reader, mut ws_writer) = ClientBuilder::new("ws://echo.websocket.org")
.unwrap()
.connect(None)
.unwrap()
.split()
.unwrap();
// use ws_reader in a thread, and ws_writer in an other thread
}
But, there is no split
method on websocket::sync::Client<Box<dyn NetworkStream + std::marker::Send>>
:
error[E0599]: no method named `split` found for struct `websocket::sync::Client<Box<dyn NetworkStream + std::marker::Send>>` in the current scope
--> src/main.rs:8:10
|
8 | .split()
| ^^^^^ method not found in `websocket::sync::Client<Box<dyn NetworkStream + std::marker::Send>>`
|
::: /home/bux/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:160:1
|
160 | / pub struct Box<
161 | | T: ?Sized,
162 | | #[unstable(feature = "allocator_api", issue = "32838")] A: AllocRef = Global,
163 | | >(Unique<T>, A);
| | -
| | |
| | doesn't satisfy `<_ as Splittable>::Reader = _`
| |________________doesn't satisfy `<_ as Splittable>::Writer = _`
| doesn't satisfy `_: Splittable`
|
= note: the method `split` exists but the following trait bounds were not satisfied:
`Box<dyn NetworkStream + std::marker::Send>: Splittable`
`<Box<dyn NetworkStream + std::marker::Send> as Splittable>::Reader = _`
`<Box<dyn NetworkStream + std::marker::Send> as Splittable>::Writer = _`
Documentation only show .split
usage with connect_insecure
. I do not understand how i can have my reader/writer by using .connect
method.
Help would be very appreciated ...