Skip to main content

RlpxProtocolMultiplexer

Struct RlpxProtocolMultiplexer 

Source
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>

Source

pub fn new(conn: P2PStream<St>) -> Self

Wraps the raw p2p stream

Source

pub fn install_protocol<F, Proto>( &mut self, cap: &Capability, f: F, ) -> Result<(), UnsupportedCapabilityError>
where F: FnOnce(ProtocolConnection) -> Proto, Proto: Stream<Item = BytesMut> + Send + 'static,

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.

Source

pub fn install_protocol_with_limits<F, Proto>( &mut self, cap: &Capability, limits: ProtocolIngressLimits, f: F, ) -> Result<(), UnsupportedCapabilityError>
where F: FnOnce(ProtocolConnection) -> Proto, Proto: Stream<Item = BytesMut> + Send + 'static,

Installs a new protocol with local limits for inbound messages.

Source

pub const fn shared_capabilities(&self) -> &SharedCapabilities

Returns the SharedCapabilities of the underlying raw p2p stream

Source

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.

Source

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.

Source

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

Source

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>
where St: Stream<Item = Result<BytesMut>> + Sink<Bytes, Error = Error> + Unpin,

Converts this multiplexer into a RlpxSatelliteStream with eth protocol as the given primary protocol and the handshake implementation.

Trait Implementations§

Source§

impl<St: Debug> Debug for RlpxProtocolMultiplexer<St>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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> NonStaticAny for T
where T: ?Sized,

§

fn type_id(&self) -> TypeId

Returns the lifetime-erased type ID of self.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

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.