[][src]Struct libp2p::swarm::OneShotHandler

pub struct OneShotHandler<TInProto, TOutProto, TOutEvent> where
    TOutProto: OutboundUpgradeSend
{ /* fields omitted */ }

Implementation of ProtocolsHandler that opens a new substream for each individual message.

This struct is meant to be a helper for other implementations to use.

Methods

impl<TInProto, TOutProto, TOutEvent> OneShotHandler<TInProto, TOutProto, TOutEvent> where
    TOutProto: OutboundUpgradeSend
[src]

pub fn new(
    listen_protocol: SubstreamProtocol<TInProto>,
    inactive_timeout: Duration
) -> OneShotHandler<TInProto, TOutProto, TOutEvent>
[src]

Creates a OneShotHandler.

pub fn pending_requests(&self) -> u32[src]

Returns the number of pending requests.

pub fn listen_protocol_ref(&self) -> &SubstreamProtocol<TInProto>[src]

Returns a reference to the listen protocol configuration.

Note: If you modify the protocol, modifications will only applies to future inbound substreams, not the ones already being negotiated.

pub fn listen_protocol_mut(&mut self) -> &mut SubstreamProtocol<TInProto>[src]

Returns a mutable reference to the listen protocol configuration.

Note: If you modify the protocol, modifications will only applies to future inbound substreams, not the ones already being negotiated.

pub fn send_request(&mut self, upgrade: TOutProto)[src]

Opens an outbound substream with upgrade.

Trait Implementations

impl<TInProto, TOutProto, TOutEvent> Default for OneShotHandler<TInProto, TOutProto, TOutEvent> where
    TInProto: InboundUpgradeSend + Default,
    TOutProto: OutboundUpgradeSend
[src]

impl<TInProto, TOutProto, TOutEvent> ProtocolsHandler for OneShotHandler<TInProto, TOutProto, TOutEvent> where
    TInProto: InboundUpgradeSend + Send + 'static,
    TOutEvent: Send + 'static,
    TOutProto: OutboundUpgradeSend,
    <TInProto as InboundUpgradeSend>::Output: Into<TOutEvent>,
    <TOutProto as OutboundUpgradeSend>::Output: Into<TOutEvent>,
    <TOutProto as OutboundUpgradeSend>::Error: Error,
    <TOutProto as OutboundUpgradeSend>::Error: Send,
    <TOutProto as OutboundUpgradeSend>::Error: 'static,
    SubstreamProtocol<TInProto>: Clone
[src]

type InEvent = TOutProto

Custom event that can be received from the outside.

type OutEvent = TOutEvent

Custom event that can be produced by the handler and that will be returned to the outside.

type Error = ProtocolsHandlerUpgrErr<<<OneShotHandler<TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundProtocol as OutboundUpgradeSend>::Error>

The type of errors returned by [ProtocolsHandler::poll].

type InboundProtocol = TInProto

The inbound upgrade for the protocol(s) used by the handler.

type OutboundProtocol = TOutProto

The outbound upgrade for the protocol(s) used by the handler.

type OutboundOpenInfo = ()

The type of additional information passed to an OutboundSubstreamRequest.

Auto Trait Implementations

impl<TInProto, TOutProto, TOutEvent> !RefUnwindSafe for OneShotHandler<TInProto, TOutProto, TOutEvent>

impl<TInProto, TOutProto, TOutEvent> Send for OneShotHandler<TInProto, TOutProto, TOutEvent> where
    TInProto: Send,
    TOutEvent: Send,
    <TOutProto as OutboundUpgradeSend>::Error: Send

impl<TInProto, TOutProto, TOutEvent> Sync for OneShotHandler<TInProto, TOutProto, TOutEvent> where
    TInProto: Sync,
    TOutEvent: Sync,
    TOutProto: Sync,
    <TOutProto as OutboundUpgradeSend>::Error: Sync

impl<TInProto, TOutProto, TOutEvent> Unpin for OneShotHandler<TInProto, TOutProto, TOutEvent> where
    TInProto: Unpin,
    TOutEvent: Unpin,
    TOutProto: Unpin,
    <TOutProto as OutboundUpgradeSend>::Error: Unpin

impl<TInProto, TOutProto, TOutEvent> !UnwindSafe for OneShotHandler<TInProto, TOutProto, TOutEvent>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized

impl<T> From<T> for T[src]

impl<T> InitializableFromZeroed for T where
    T: Default

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoProtocolsHandler for T where
    T: ProtocolsHandler
[src]

type Handler = T

The protocols handler.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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