Now I'm trying to build a nodejs addon for websocket conversation.
This is the connect part of my code:
impl Finalize for WebSocketClient {}
fn connect(mut cx: FunctionContext) -> JsResult<JsBox<Arc<Mutex<WebSocketClient>>>> {
let url = cx.argument::<JsString>(0)?.value(&mut cx);
let client = Arc::new(Mutex::new(WebSocketClient::new()));
let rt = Runtime::new().unwrap();
let client_clone = Arc::clone(&client);
rt.block_on(async {
let mut client_guard = client_clone.lock().await;
client_guard.connect(url);
});
Ok(cx.boxed(client_clone))
}
And at the last row, I got this error:
the trait bound tokio::sync::Mutex<WebSocketClient>: neon::prelude::Finalize
is not satisfied
the following other types implement trait neon::prelude::Finalize
:
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
(T0, T1, T2, T3, T4, T5, T6, T7)
I just started Rust a few days ago, so I can't find what to do with this error.
Somebody help me, please.