mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 01:51:23 +00:00
core/muxing: Generalise StreamMuxer::poll_address_change
to poll
(#2797)
This is to allow general-purpose background work to be performed by implementations.
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use crate::muxing::StreamMuxerEvent;
|
||||
use crate::{
|
||||
muxing::StreamMuxer,
|
||||
transport::{ListenerId, Transport, TransportError, TransportEvent},
|
||||
@ -236,24 +237,22 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_address_change(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Result<Multiaddr, Self::Error>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(inner) => inner.poll_address_change(cx).map_err(EitherError::A),
|
||||
EitherOutputProj::Second(inner) => {
|
||||
inner.poll_address_change(cx).map_err(EitherError::B)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(inner) => inner.poll_close(cx).map_err(EitherError::A),
|
||||
EitherOutputProj::Second(inner) => inner.poll_close(cx).map_err(EitherError::B),
|
||||
}
|
||||
}
|
||||
|
||||
fn poll(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Result<StreamMuxerEvent, Self::Error>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(inner) => inner.poll(cx).map_err(EitherError::A),
|
||||
EitherOutputProj::Second(inner) => inner.poll(cx).map_err(EitherError::B),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Implements `Future` and dispatches all method calls to either `First` or `Second`.
|
||||
|
Reference in New Issue
Block a user