How to implement UnboundedSender<Response>? #3794
-
#[derive(NetworkBehaviour)]
#[behaviour(out_event = "MyEvent")]
struct MyBehaviour {
gossipsub: gossipsub::Behaviour,
mdns: mdns::async_io::Behaviour,
response_sender: UnboundedSender<Response>,
}
enum MyEvent {
GossipsubEvent(gossipsub::Event),
MdnsEvent(mdns::Event)
}
impl From<gossipsub::Event> for MyEvent {
fn from(event: gossipsub::Event) -> Self {
Self::GossipsubEvent(event)
}
}
impl From<mdns::Event> for MyEvent {
fn from(event: mdns::Event) -> Self {
Self::MdnsEvent(event)
}
} error[E0277]: the trait bound `MyEvent: From<<tokio::sync::mpsc::UnboundedSender<Response> as NetworkBehaviour>::OutEvent>` is not satisfied
--> src/main.rs:56:10
|
56 | #[derive(NetworkBehaviour)]
| ^^^^^^^^^^^^^^^^ the trait `From<<tokio::sync::mpsc::UnboundedSender<Response> as NetworkBehaviour>::OutEvent>` is not implemented for `MyEvent`
|
= help: the following other types implement trait `From<T>`:
<MyEvent as From<libp2p::libp2p_gossipsub::Event>>
<MyEvent as From<libp2p::libp2p_mdns::Event>>
= help: see issue #48214
= note: this error originates in the derive macro `NetworkBehaviour` (in Nightly builds, run with -Z macro-backtrace for more info) Later, i could use #[behaviour(ignore)]. |
Beta Was this translation helpful? Give feedback.
Answered by
thomaseizinger
Apr 16, 2023
Replies: 1 comment 1 reply
-
You should not have a Sender in your behaviour struct but instead handle the events from Have you seen the file-sharing example? |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
thomaseizinger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should not have a Sender in your behaviour struct but instead handle the events from
Swarm
via thenext().await
function.Have you seen the file-sharing example?