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 as RequestResponseCodec>::Protocol: Sync,
[src]
C: RequestResponseCodec + Send + Clone,
<C as RequestResponseCodec>::Protocol: Sync,
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]
C: Send,
I: IntoIterator<Item = (<C as RequestResponseCodec>::Protocol, ProtocolSupport)>,
<C as RequestResponseCodec>::Protocol: Sync,
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]
&mut self,
p: &PeerId,
req: <C as RequestResponseCodec>::Request
) -> Result<RequestId, <C as RequestResponseCodec>::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 as RequestResponseCodec>::Response>>,
res: <C as RequestResponseCodec>::Response
)
[src]
&mut self,
ch: ResponseChannel<Message<<C as RequestResponseCodec>::Response>>,
res: <C as RequestResponseCodec>::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 as RequestResponseCodec>::Protocol: Sync,
[src]
C: RequestResponseCodec + Send + Clone + 'static,
<C as RequestResponseCodec>::Protocol: Sync,
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.
pub fn new_handler(
&mut self
) -> <Throttled<C> as NetworkBehaviour>::ProtocolsHandler
[src]
&mut self
) -> <Throttled<C> as NetworkBehaviour>::ProtocolsHandler
pub fn addresses_of_peer(&mut self, p: &PeerId) -> Vec<Multiaddr, Global>
[src]
pub fn inject_connection_established(
&mut self,
p: &PeerId,
id: &ConnectionId,
end: &ConnectedPoint
)
[src]
&mut self,
p: &PeerId,
id: &ConnectionId,
end: &ConnectedPoint
)
pub fn inject_connection_closed(
&mut self,
peer: &PeerId,
id: &ConnectionId,
end: &ConnectedPoint
)
[src]
&mut self,
peer: &PeerId,
id: &ConnectionId,
end: &ConnectedPoint
)
pub fn inject_connected(&mut self, p: &PeerId)
[src]
pub fn inject_disconnected(&mut self, p: &PeerId)
[src]
pub fn inject_dial_failure(&mut self, p: &PeerId)
[src]
pub fn inject_event(
&mut self,
p: PeerId,
i: ConnectionId,
e: RequestResponseHandlerEvent<Codec<C>>
)
[src]
&mut self,
p: PeerId,
i: ConnectionId,
e: RequestResponseHandlerEvent<Codec<C>>
)
pub fn poll(
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<RequestProtocol<Codec<C>>, <Throttled<C> as NetworkBehaviour>::OutEvent>>
[src]
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<RequestProtocol<Codec<C>>, <Throttled<C> as NetworkBehaviour>::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>,