Struct libp2p_request_response::throttled::Throttled  [−][src]
A wrapper around RequestResponse which adds request limits per peer.
Implementations
impl<C> Throttled<C> where
    C: RequestResponseCodec + Send + Clone,
    C::Protocol: Sync, [src]
C: RequestResponseCodec + Send + Clone,
C::Protocol: Sync,
pub fn new<I>(c: C, protos: I, cfg: RequestResponseConfig) -> Self where
    I: IntoIterator<Item = (C::Protocol, ProtocolSupport)>,
    C: Send,
    C::Protocol: Sync, [src]
I: IntoIterator<Item = (C::Protocol, ProtocolSupport)>,
C: Send,
C::Protocol: Sync,
Create a new throttled request-response behaviour.
pub fn from(behaviour: RequestResponse<Codec<C>>) -> Self[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::Request
) -> Result<RequestId, C::Request>[src]
&mut self,
p: &PeerId,
req: C::Request
) -> Result<RequestId, C::Request>
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::Response>>, 
    res: C::Response
)[src]
&mut self,
ch: ResponseChannel<Message<C::Response>>,
res: C::Response
)
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::Protocol: Sync, [src]
C: RequestResponseCodec + Send + Clone + 'static,
C::Protocol: Sync,
type ProtocolsHandler = RequestResponseHandler<Codec<C>>
Handler for all the protocols the network behaviour supports.
type OutEvent = Event<C::Request, C::Response, Message<C::Response>>
Event generated by the NetworkBehaviour and that the swarm will report back.
fn new_handler(&mut self) -> Self::ProtocolsHandler[src]
fn addresses_of_peer(&mut self, p: &PeerId) -> Vec<Multiaddr>[src]
fn inject_connection_established(
    &mut self, 
    p: &PeerId, 
    id: &ConnectionId, 
    end: &ConnectedPoint
)[src]
&mut self,
p: &PeerId,
id: &ConnectionId,
end: &ConnectedPoint
)
fn inject_connection_closed(
    &mut self, 
    peer: &PeerId, 
    id: &ConnectionId, 
    end: &ConnectedPoint
)[src]
&mut self,
peer: &PeerId,
id: &ConnectionId,
end: &ConnectedPoint
)
fn inject_connected(&mut self, p: &PeerId)[src]
fn inject_disconnected(&mut self, p: &PeerId)[src]
fn inject_dial_failure(&mut self, p: &PeerId)[src]
fn inject_event(
    &mut self, 
    p: PeerId, 
    i: ConnectionId, 
    e: RequestResponseHandlerEvent<Codec<C>>
)[src]
&mut self,
p: PeerId,
i: ConnectionId,
e: RequestResponseHandlerEvent<Codec<C>>
)
fn poll(
    &mut self, 
    cx: &mut Context<'_>, 
    params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<RequestProtocol<Codec<C>>, Self::OutEvent>>[src]
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<RequestProtocol<Codec<C>>, Self::OutEvent>>
pub fn inject_address_change(
    &mut self, 
    &PeerId, 
    &ConnectionId, 
    _old: &ConnectedPoint, 
    _new: &ConnectedPoint
)[src]
&mut self,
&PeerId,
&ConnectionId,
_old: &ConnectedPoint,
_new: &ConnectedPoint
)
pub fn inject_addr_reach_failure(
    &mut self, 
    _peer_id: Option<&PeerId>, 
    _addr: &Multiaddr, 
    _error: &dyn Error
)[src]
&mut self,
_peer_id: Option<&PeerId>,
_addr: &Multiaddr,
_error: &dyn Error
)
pub fn inject_new_listen_addr(&mut self, _addr: &Multiaddr)[src]
pub fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)[src]
pub fn inject_new_external_addr(&mut self, _addr: &Multiaddr)[src]
pub fn inject_listener_error(
    &mut self, 
    _id: ListenerId, 
    _err: &(dyn Error + 'static)
)[src]
&mut self,
_id: ListenerId,
_err: &(dyn Error + 'static)
)
pub fn inject_listener_closed(
    &mut self, 
    _id: ListenerId, 
    _reason: Result<(), &Error>
)[src]
&mut self,
_id: ListenerId,
_reason: Result<(), &Error>
)
Auto Trait Implementations
impl<C> !RefUnwindSafe for Throttled<C>
impl<C> Send for Throttled<C>
impl<C> Sync for Throttled<C> where
    C: Sync,
    <C as RequestResponseCodec>::Request: Sync,
    <C as RequestResponseCodec>::Response: Sync, 
C: Sync,
<C as RequestResponseCodec>::Request: Sync,
<C as RequestResponseCodec>::Response: 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, 
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
    T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
    T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
    U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T[src]
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
    U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
    V: MultiLane<T>, [src]
V: MultiLane<T>,