Skip to content

Commit

Permalink
feat: remove Send bound from NetworkBehaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Feb 24, 2022
1 parent b185946 commit 0c5fa28
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion protocols/dcutr/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl From<dcutr::behaviour::Event> for ClientEvent {
}
}

fn spawn_swarm_on_pool<B: NetworkBehaviour>(pool: &LocalPool, swarm: Swarm<B>) {
fn spawn_swarm_on_pool<B: NetworkBehaviour + Send>(pool: &LocalPool, swarm: Swarm<B>) {
pool.spawner()
.spawn_obj(swarm.collect::<Vec<_>>().map(|_| ()).boxed().into())
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/tests/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ fn build_keep_alive_only_swarm() -> Swarm<DummyBehaviour> {
)
}

fn spawn_swarm_on_pool<B: NetworkBehaviour>(pool: &LocalPool, mut swarm: Swarm<B>) {
fn spawn_swarm_on_pool<B: NetworkBehaviour + Send>(pool: &LocalPool, mut swarm: Swarm<B>) {
pool.spawner()
.spawn_obj(
async move {
Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/tests/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ impl From<PingEvent> for ClientEvent {
}
}

fn spawn_swarm_on_pool<B: NetworkBehaviour>(pool: &LocalPool, swarm: Swarm<B>) {
fn spawn_swarm_on_pool<B: NetworkBehaviour + Send>(pool: &LocalPool, swarm: Swarm<B>) {
pool.spawner()
.spawn_obj(swarm.collect::<Vec<_>>().map(|_| ()).boxed().into())
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions protocols/rendezvous/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub trait SwarmExt {
/// Establishes a connection to the given [`Swarm`], polling both of them until the connection is established.
async fn block_on_connection<T>(&mut self, other: &mut Swarm<T>)
where
T: NetworkBehaviour,
T: NetworkBehaviour + Send,
<T as NetworkBehaviour>::OutEvent: Debug;

/// Listens on a random memory address, polling the [`Swarm`] until the transport is ready to accept connections.
Expand All @@ -153,12 +153,12 @@ pub trait SwarmExt {
#[async_trait]
impl<B> SwarmExt for Swarm<B>
where
B: NetworkBehaviour,
B: NetworkBehaviour + Send,
<B as NetworkBehaviour>::OutEvent: Debug,
{
async fn block_on_connection<T>(&mut self, other: &mut Swarm<T>)
where
T: NetworkBehaviour,
T: NetworkBehaviour + Send,
<T as NetworkBehaviour>::OutEvent: Debug,
{
let addr_to_dial = other.external_addresses().next().unwrap().addr.clone();
Expand Down
5 changes: 5 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

# Unreleased

- Remove `Send` bound from `NetworkBehaviour`.

# 0.34.0 [2022-02-22]

- Rename `ProtocolsHandler` to `ConnectionHandler`. Upgrade should be as simple as renaming all
Expand Down
2 changes: 1 addition & 1 deletion swarm/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub(crate) type THandlerOutEvent<THandler> =
/// Optionally one can provide a custom `poll` function through the `#[behaviour(poll_method =
/// "poll")]` attribute. This function must have the same signature as the [`NetworkBehaviour#poll`]
/// function and will be called last within the generated [`NetworkBehaviour`] implementation.
pub trait NetworkBehaviour: Send + 'static {
pub trait NetworkBehaviour: 'static {
/// Handler for all the protocols the network behaviour supports.
type ConnectionHandler: IntoConnectionHandler;

Expand Down

0 comments on commit 0c5fa28

Please sign in to comment.