GitHub - rasviitanen/rustysignal: Signal...

Hey guys trying to build a Signalling Server with Rust based on this repo: https://github.com/rasviitanen/rustysignal/tree/master Facing some issues when accounting for worker-rs instead. Here's some code:
pub struct Node {
pub owner: Option<String>,
pub sender: WebSocket
}

impl Node {

pub fn new(owner: Option<String>, sender: WebSocket) -> Self {
Self { owner, sender }
}
}

#[durable_object]
pub struct Network {
pub nodemap: Vec<Node>,
state: State,
env:Env,
}

#[durable_object]
impl DurableObject for Network {
fn new(state: State, env: Env) -> Self {
Self {
nodemap: vec![],
state: state,
env,
}
}


pub struct Node {
pub owner: Option<String>,
pub sender: WebSocket
}

impl Node {

pub fn new(owner: Option<String>, sender: WebSocket) -> Self {
Self { owner, sender }
}
}

#[durable_object]
pub struct Network {
pub nodemap: Vec<Node>,
state: State,
env:Env,
}

#[durable_object]
impl DurableObject for Network {
fn new(state: State, env: Env) -> Self {
Self {
nodemap: vec![],
state: state,
env,
}
}


I notice that the durable object macro panics with this error:
error[E0277]: the trait bound `Node: JsObject` is not satisfied
--> src/lib.rs:15:1
|
15 | #[durable_object]
| ^^^^^^^^^^^^^^^^^ the trait `JsObject` is not implemented for `Node`
|
= help: the following other types implement trait `JsObject`:
ext::abort_controller::glue::AbortController
worker::worker_sys::web_sys::AbortController
ext::abort_signal::glue::AbortSignal
ext::cache_storage::glue::CacheStorage
worker::worker_sys::web_sys::AbortSignal
ext::headers::glue::Headers
ext::request::glue::Request
Array
and 113 others
= note: required for `Box<[Node]>` to implement `IntoWasmAbi`
= note: 1 redundant requirement hidden
= note: required for `Vec<Node>` to implement `IntoWasmAbi`
= note: this error originates in the attribute macro `wasm_bindgen::prelude::wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `Node: JsObject` is not satisfied
--> src/lib.rs:15:1
|
15 | #[durable_object]
| ^^^^^^^^^^^^^^^^^ the trait `JsObject` is not implemented for `Node`
|
= help: the following other types implement trait `JsObject`:
ext::abort_controller::glue::AbortController
worker::worker_sys::web_sys::AbortController
ext::abort_signal::glue::AbortSignal
ext::cache_storage::glue::CacheStorage
worker::worker_sys::web_sys::AbortSignal
ext::headers::glue::Headers
ext::request::glue::Request
Array
and 113 others
= note: required for `Box<[Node]>` to implement `IntoWasmAbi`
= note: 1 redundant requirement hidden
= note: required for `Vec<Node>` to implement `IntoWasmAbi`
= note: this error originates in the attribute macro `wasm_bindgen::prelude::wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)
How do I go about it?
GitHub
GitHub - rasviitanen/rustysignal: Signaling server for WebRTC that ...
Signaling server for WebRTC that supports SSL-encrypted connections - GitHub - rasviitanen/rustysignal: Signaling server for WebRTC that supports SSL-encrypted connections
2 Replies
radix
radix14mo ago
This is interesting. I was able to reproduce your problem but only when the nodemap field is pub. Maybe this is just some random bug in the durable_object macro? can you get by keeping nodemap as private?
onlyartist9
onlyartist9OP14mo ago
Hey radix. Yeah it works thanks!
Want results from more Discord servers?
Add your server