rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

swarm/src/behaviour: Add `AndBehaviour`

Open mxinden opened this issue 3 years ago • 0 comments

Description

To combine two NetworkBehaviour implementations libp2p-swarm should provide a combinator. Contrary to NetworkBehaviour implementation of Either both NetworkBehaviour implementations would be running concurrently.

Motivation

One use-case is when wanting to either enable two NetworkBehaviours or disable both, but never enable one but disable the other.

Toggle<And<BehaviourA, BehaviourB>>

Came up here: https://github.com/n0-computer/iroh/pull/126#discussion_r901236064

Requirements

Open questions

  • What is the ideal name? Off the top of my head it should be And.

Are you planning to do it yourself in a pull request?

No. Though happy to support anyone interested in contributing this.

mxinden avatar Jun 21 '22 03:06 mxinden