pub struct RlpxProtocolMultiplexer<St> { /* private fields */ }Expand description
A Stream and Sink type that wraps a raw rlpx stream P2PStream and handles message ID
multiplexing.
Implementations§
Source§impl<St> RlpxProtocolMultiplexer<St>
impl<St> RlpxProtocolMultiplexer<St>
Sourcepub fn install_protocol<F, Proto>(
&mut self,
cap: &Capability,
f: F,
) -> Result<(), UnsupportedCapabilityError>
pub fn install_protocol<F, Proto>( &mut self, cap: &Capability, f: F, ) -> Result<(), UnsupportedCapabilityError>
Installs a new protocol on top of the raw p2p stream.
This accepts a closure that receives a ProtocolConnection that will yield messages for
the given capability.
Sourcepub fn install_protocol_with_limits<F, Proto>(
&mut self,
cap: &Capability,
limits: ProtocolIngressLimits,
f: F,
) -> Result<(), UnsupportedCapabilityError>
pub fn install_protocol_with_limits<F, Proto>( &mut self, cap: &Capability, limits: ProtocolIngressLimits, f: F, ) -> Result<(), UnsupportedCapabilityError>
Installs a new protocol with local limits for inbound messages.
Returns the SharedCapabilities of the underlying raw p2p stream
Sourcepub fn into_satellite_stream<F, Primary>(
self,
cap: &Capability,
primary: F,
) -> Result<RlpxSatelliteStream<St, Primary>, P2PStreamError>where
F: FnOnce(ProtocolProxy) -> Primary,
pub fn into_satellite_stream<F, Primary>(
self,
cap: &Capability,
primary: F,
) -> Result<RlpxSatelliteStream<St, Primary>, P2PStreamError>where
F: FnOnce(ProtocolProxy) -> Primary,
Converts this multiplexer into a RlpxSatelliteStream with the given primary protocol.
Sourcepub async fn into_satellite_stream_with_handshake<F, Fut, Err, Primary>(
self,
cap: &Capability,
handshake: F,
) -> Result<RlpxSatelliteStream<St, Primary>, Err>where
F: FnOnce(ProtocolProxy) -> Fut,
Fut: Future<Output = Result<Primary, Err>>,
St: Stream<Item = Result<BytesMut>> + Sink<Bytes, Error = Error> + Unpin,
P2PStreamError: Into<Err>,
pub async fn into_satellite_stream_with_handshake<F, Fut, Err, Primary>(
self,
cap: &Capability,
handshake: F,
) -> Result<RlpxSatelliteStream<St, Primary>, Err>where
F: FnOnce(ProtocolProxy) -> Fut,
Fut: Future<Output = Result<Primary, Err>>,
St: Stream<Item = Result<BytesMut>> + Sink<Bytes, Error = Error> + Unpin,
P2PStreamError: Into<Err>,
Converts this multiplexer into a RlpxSatelliteStream with the given primary protocol.
Returns an error if the primary protocol is not supported by the remote or the handshake failed.
Sourcepub async fn into_satellite_stream_with_tuple_handshake<F, Fut, Err, Primary, Extra>(
self,
cap: &Capability,
handshake: F,
) -> Result<(RlpxSatelliteStream<St, Primary>, Extra), Err>where
F: FnOnce(ProtocolProxy) -> Fut,
Fut: Future<Output = Result<(Primary, Extra), Err>>,
St: Stream<Item = Result<BytesMut>> + Sink<Bytes, Error = Error> + Unpin,
P2PStreamError: Into<Err>,
pub async fn into_satellite_stream_with_tuple_handshake<F, Fut, Err, Primary, Extra>(
self,
cap: &Capability,
handshake: F,
) -> Result<(RlpxSatelliteStream<St, Primary>, Extra), Err>where
F: FnOnce(ProtocolProxy) -> Fut,
Fut: Future<Output = Result<(Primary, Extra), Err>>,
St: Stream<Item = Result<BytesMut>> + Sink<Bytes, Error = Error> + Unpin,
P2PStreamError: Into<Err>,
Converts this multiplexer into a RlpxSatelliteStream with the given primary protocol.
Returns an error if the primary protocol is not supported by the remote or the handshake failed.
This accepts a closure that does a handshake with the remote peer and returns a tuple of the primary stream and extra data.
See also UnauthedEthStream::handshake
Sourcepub async fn into_eth_satellite_stream<N: NetworkPrimitives>(
self,
status: UnifiedStatus,
fork_filter: ForkFilter,
handshake: Arc<dyn EthRlpxHandshake>,
eth_max_message_size: usize,
) -> Result<(RlpxSatelliteStream<St, EthStream<ProtocolProxy, N>>, UnifiedStatus), EthStreamError>
pub async fn into_eth_satellite_stream<N: NetworkPrimitives>( self, status: UnifiedStatus, fork_filter: ForkFilter, handshake: Arc<dyn EthRlpxHandshake>, eth_max_message_size: usize, ) -> Result<(RlpxSatelliteStream<St, EthStream<ProtocolProxy, N>>, UnifiedStatus), EthStreamError>
Converts this multiplexer into a RlpxSatelliteStream with eth protocol as the given
primary protocol and the handshake implementation.
Trait Implementations§
Auto Trait Implementations§
impl<St> !RefUnwindSafe for RlpxProtocolMultiplexer<St>
impl<St> !Sync for RlpxProtocolMultiplexer<St>
impl<St> !UnwindSafe for RlpxProtocolMultiplexer<St>
impl<St> Freeze for RlpxProtocolMultiplexer<St>where
MultiplexInner<St>: Freeze,
impl<St> Send for RlpxProtocolMultiplexer<St>where
MultiplexInner<St>: Send,
impl<St> Unpin for RlpxProtocolMultiplexer<St>where
MultiplexInner<St>: Unpin,
impl<St> UnsafeUnpin for RlpxProtocolMultiplexer<St>where
MultiplexInner<St>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.