[][src]Struct libp2p::request_response::Throttled

pub struct Throttled<C> where
    C: RequestResponseCodec + Send,
    <C as RequestResponseCodec>::Protocol: Sync
{ /* fields omitted */ }

A wrapper around RequestResponse which adds request limits per peer.

Implementations

impl<C> Throttled<C> where
    C: RequestResponseCodec + Send + Clone,
    <C as RequestResponseCodec>::Protocol: Sync
[src]

pub fn new<I>(c: C, protos: I, cfg: RequestResponseConfig) -> Throttled<C> where
    C: Send,
    I: IntoIterator<Item = (<C as RequestResponseCodec>::Protocol, ProtocolSupport)>,
    <C as RequestResponseCodec>::Protocol: Sync
[src]

Create a new throttled request-response behaviour.

pub fn from(behaviour: RequestResponse<Codec<C>>) -> Throttled<C>[src]

Wrap an existing RequestResponse behaviour and apply send/recv limits.

pub fn set_receive_limit(&mut self, limit: NonZeroU16)[src]

Set the global default receive limit per peer.

pub fn override_receive_limit(&mut self, p: &PeerId, limit: NonZeroU16)[src]

Override the receive limit of a single peer.

pub fn remove_override(&mut self, p: &PeerId)[src]

Remove any limit overrides for the given peer.

pub fn can_send(&mut self, p: &PeerId) -> bool[src]

Has the limit of outbound requests been reached for the given peer?

pub fn send_request(
    &mut self,
    p: &PeerId,
    req: <C as RequestResponseCodec>::Request
) -> Result<RequestId, <C as RequestResponseCodec>::Request>
[src]

Send a request to a peer.

If the limit of outbound requests has been reached, the request is returned. Sending more outbound requests should only be attempted once Event::ResumeSending has been received from NetworkBehaviour::poll.

pub fn send_response(
    &mut self,
    ch: ResponseChannel<Message<<C as RequestResponseCodec>::Response>>,
    res: <C as RequestResponseCodec>::Response
)
[src]

Answer an inbound request with a response.

See RequestResponse::send_response for details.

pub fn add_address(&mut self, p: &PeerId, a: Multiaddr)[src]

Add a known peer address.

See RequestResponse::add_address for details.

pub fn remove_address(&mut self, p: &PeerId, a: &Multiaddr)[src]

Remove a previously added peer address.

See RequestResponse::remove_address for details.

pub fn is_connected(&self, p: &PeerId) -> bool[src]

Are we connected to the given peer?

See RequestResponse::is_connected for details.

pub fn is_pending_outbound(&self, p: &RequestId) -> bool[src]

Are we waiting for a response to the given request?

See RequestResponse::is_pending_outbound for details.

Trait Implementations

impl<C> NetworkBehaviour for Throttled<C> where
    C: RequestResponseCodec + Send + Clone + 'static,
    <C as RequestResponseCodec>::Protocol: Sync
[src]

type ProtocolsHandler = RequestResponseHandler<Codec<C>>

Handler for all the protocols the network behaviour supports.

type OutEvent = Event<<C as RequestResponseCodec>::Request, <C as RequestResponseCodec>::Response, Message<<C as RequestResponseCodec>::Response>>

Event generated by the NetworkBehaviour and that the swarm will report back.

Auto Trait Implementations

impl<C> !RefUnwindSafe for Throttled<C>

impl<C> Send for Throttled<C> where
    <C as RequestResponseCodec>::Protocol: Send,
    <C as RequestResponseCodec>::Request: Send,
    <C as RequestResponseCodec>::Response: Send

impl<C> Sync for Throttled<C> where
    C: Sync,
    <C as RequestResponseCodec>::Request: Sync,
    <C as RequestResponseCodec>::Response: Send + Sync

impl<C> Unpin for Throttled<C> where
    C: Unpin,
    <C as RequestResponseCodec>::Protocol: Unpin,
    <C as RequestResponseCodec>::Request: Unpin,
    <C as RequestResponseCodec>::Response: Unpin

impl<C> !UnwindSafe for Throttled<C>

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> From<T> for T[src]

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

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