Skip to content

Commit

Permalink
Add map_protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka committed Oct 24, 2018
1 parent 4c5b51b commit d77f092
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/src/nodes/protocols_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,26 @@ impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom>
}
}

/// If this is `OutboundSubstreamRequest`, maps the protocol to another.
#[inline]
pub fn map_protocol<F, I>(
self,
map: F,
) -> ProtocolsHandlerEvent<I, TOutboundOpenInfo, TCustom>
where
F: FnOnce(TConnectionUpgrade) -> I,
{
match self {
ProtocolsHandlerEvent::OutboundSubstreamRequest { upgrade, info } => {
ProtocolsHandlerEvent::OutboundSubstreamRequest {
upgrade: map(upgrade),
info,
}
}
ProtocolsHandlerEvent::Custom(val) => ProtocolsHandlerEvent::Custom(val),
}
}

/// If this is `Custom`, maps the content to something else.
#[inline]
pub fn map_custom<F, I>(
Expand Down

0 comments on commit d77f092

Please sign in to comment.