mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 01:51:23 +00:00
core/muxing: Introduce StreamMuxerEvent::map_inbound_stream
(#2691)
Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@ -210,22 +210,14 @@ where
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Result<StreamMuxerEvent<Self::Substream>, Self::Error>> {
|
||||
match self {
|
||||
EitherOutput::First(inner) => inner.poll_event(cx).map(|result| {
|
||||
result.map_err(|e| e.into()).map(|event| match event {
|
||||
StreamMuxerEvent::AddressChange(addr) => StreamMuxerEvent::AddressChange(addr),
|
||||
StreamMuxerEvent::InboundSubstream(substream) => {
|
||||
StreamMuxerEvent::InboundSubstream(EitherOutput::First(substream))
|
||||
}
|
||||
})
|
||||
}),
|
||||
EitherOutput::Second(inner) => inner.poll_event(cx).map(|result| {
|
||||
result.map_err(|e| e.into()).map(|event| match event {
|
||||
StreamMuxerEvent::AddressChange(addr) => StreamMuxerEvent::AddressChange(addr),
|
||||
StreamMuxerEvent::InboundSubstream(substream) => {
|
||||
StreamMuxerEvent::InboundSubstream(EitherOutput::Second(substream))
|
||||
}
|
||||
})
|
||||
}),
|
||||
EitherOutput::First(inner) => inner
|
||||
.poll_event(cx)
|
||||
.map_err(|e| e.into())
|
||||
.map_ok(|event| event.map_inbound_stream(EitherOutput::First)),
|
||||
EitherOutput::Second(inner) => inner
|
||||
.poll_event(cx)
|
||||
.map_err(|e| e.into())
|
||||
.map_ok(|event| event.map_inbound_stream(EitherOutput::Second)),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user