mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-22 06:11:34 +00:00
Automatic fixes by cargo-fix (#1662)
This commit is contained in:
@ -257,7 +257,7 @@ where
|
||||
|
||||
/// Polls the connection for events produced by the associated handler
|
||||
/// as a result of I/O activity on the substream multiplexer.
|
||||
pub fn poll(mut self: Pin<&mut Self>, cx: &mut Context)
|
||||
pub fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>)
|
||||
-> Poll<Result<Event<THandler::OutEvent>, ConnectionError<THandler::Error>>>
|
||||
{
|
||||
loop {
|
||||
|
@ -64,7 +64,7 @@ pub trait ConnectionHandler {
|
||||
/// Polls the handler for events.
|
||||
///
|
||||
/// Returning an error will close the connection to the remote.
|
||||
fn poll(&mut self, cx: &mut Context)
|
||||
fn poll(&mut self, cx: &mut Context<'_>)
|
||||
-> Poll<Result<ConnectionHandlerEvent<Self::OutboundOpenInfo, Self::OutEvent>, Self::Error>>;
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ where
|
||||
}
|
||||
|
||||
/// Provides an API similar to `Stream`, except that it cannot end.
|
||||
pub fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<ListenersEvent<TTrans>> {
|
||||
pub fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<ListenersEvent<TTrans>> {
|
||||
// We remove each element from `listeners` one by one and add them back.
|
||||
let mut remaining = self.listeners.len();
|
||||
while let Some(mut listener) = self.listeners.pop_back() {
|
||||
@ -310,7 +310,7 @@ where
|
||||
{
|
||||
type Item = ListenersEvent<TTrans>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
ListenersStream::poll(self, cx).map(Option::Some)
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ impl<I, O, H, E, HE, C> fmt::Debug for Manager<I, O, H, E, HE, C>
|
||||
where
|
||||
C: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_map()
|
||||
.entries(self.tasks.iter().map(|(id, task)| (id, &task.state)))
|
||||
.finish()
|
||||
@ -346,7 +346,7 @@ impl<I, O, H, TE, HE, C> Manager<I, O, H, TE, HE, C> {
|
||||
}
|
||||
|
||||
/// Polls the manager for events relating to the managed connections.
|
||||
pub fn poll<'a>(&'a mut self, cx: &mut Context) -> Poll<Event<'a, I, O, H, TE, HE, C>> {
|
||||
pub fn poll<'a>(&'a mut self, cx: &mut Context<'_>) -> Poll<Event<'a, I, O, H, TE, HE, C>> {
|
||||
// Advance the content of `local_spawns`.
|
||||
while let Poll::Ready(Some(_)) = Stream::poll_next(Pin::new(&mut self.local_spawns), cx) {}
|
||||
|
||||
@ -468,7 +468,7 @@ impl<'a, I, C> EstablishedEntry<'a, I, C> {
|
||||
///
|
||||
/// Returns `Err(())` if the background task associated with the connection
|
||||
/// is terminating and the connection is about to close.
|
||||
pub fn poll_ready_notify_handler(&mut self, cx: &mut Context) -> Poll<Result<(),()>> {
|
||||
pub fn poll_ready_notify_handler(&mut self, cx: &mut Context<'_>) -> Poll<Result<(),()>> {
|
||||
self.task.get_mut().sender.poll_ready(cx).map_err(|_| ())
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ where
|
||||
// NOTE: It is imperative to always consume all incoming commands from
|
||||
// the manager first, in order to not prevent it from making progress because
|
||||
// it is blocked on the channel capacity.
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<()> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
|
||||
let this = &mut *self;
|
||||
let id = this.id;
|
||||
|
||||
|
@ -217,7 +217,7 @@ where
|
||||
&mut self,
|
||||
future: TFut,
|
||||
handler: THandler,
|
||||
info: IncomingInfo,
|
||||
info: IncomingInfo<'_>,
|
||||
) -> Result<ConnectionId, ConnectionLimit>
|
||||
where
|
||||
TConnInfo: ConnectionInfo<PeerId = TPeerId> + Send + 'static,
|
||||
@ -254,7 +254,7 @@ where
|
||||
&mut self,
|
||||
future: TFut,
|
||||
handler: THandler,
|
||||
info: OutgoingInfo<TPeerId>,
|
||||
info: OutgoingInfo<'_, TPeerId>,
|
||||
) -> Result<ConnectionId, ConnectionLimit>
|
||||
where
|
||||
TConnInfo: ConnectionInfo<PeerId = TPeerId> + Send + 'static,
|
||||
@ -562,7 +562,7 @@ where
|
||||
///
|
||||
/// > **Note**: We use a regular `poll` method instead of implementing `Stream`,
|
||||
/// > because we want the `Pool` to stay borrowed if necessary.
|
||||
pub fn poll<'a>(&'a mut self, cx: &mut Context) -> Poll<
|
||||
pub fn poll<'a>(&'a mut self, cx: &mut Context<'_>) -> Poll<
|
||||
PoolEvent<'a, TInEvent, TOutEvent, THandler, TTransErr, THandlerErr, TConnInfo, TPeerId>
|
||||
> where
|
||||
TConnInfo: ConnectionInfo<PeerId = TPeerId> + Clone,
|
||||
@ -793,7 +793,7 @@ where
|
||||
///
|
||||
/// Returns `Err(())` if the background task associated with the connection
|
||||
/// is terminating and the connection is about to close.
|
||||
pub fn poll_ready_notify_handler(&mut self, cx: &mut Context) -> Poll<Result<(),()>> {
|
||||
pub fn poll_ready_notify_handler(&mut self, cx: &mut Context<'_>) -> Poll<Result<(),()>> {
|
||||
self.entry.poll_ready_notify_handler(cx)
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ where
|
||||
}
|
||||
|
||||
/// Provides an API similar to `Future`.
|
||||
pub fn poll(&mut self, cx: &mut Context) -> Poll<Result<SubstreamEvent<TMuxer, TUserData>, IoError>> {
|
||||
pub fn poll(&mut self, cx: &mut Context<'_>) -> Poll<Result<SubstreamEvent<TMuxer, TUserData>, IoError>> {
|
||||
// Polling inbound substream.
|
||||
match self.inner.poll_event(cx) {
|
||||
Poll::Ready(Ok(StreamMuxerEvent::InboundSubstream(substream))) => {
|
||||
@ -224,7 +224,7 @@ where
|
||||
{
|
||||
type Output = Result<(), IoError>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
match self.muxer.close(cx) {
|
||||
Poll::Pending => Poll::Pending,
|
||||
Poll::Ready(Ok(())) => Poll::Ready(Ok(())),
|
||||
|
@ -74,14 +74,14 @@ where
|
||||
A: AsyncRead,
|
||||
B: AsyncRead,
|
||||
{
|
||||
fn poll_read(self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll<Result<usize, IoError>> {
|
||||
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<Result<usize, IoError>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(a) => AsyncRead::poll_read(a, cx, buf),
|
||||
EitherOutputProj::Second(b) => AsyncRead::poll_read(b, cx, buf),
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_read_vectored(self: Pin<&mut Self>, cx: &mut Context, bufs: &mut [IoSliceMut])
|
||||
fn poll_read_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>])
|
||||
-> Poll<Result<usize, IoError>>
|
||||
{
|
||||
match self.project() {
|
||||
@ -96,14 +96,14 @@ where
|
||||
A: AsyncWrite,
|
||||
B: AsyncWrite,
|
||||
{
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<Result<usize, IoError>> {
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, IoError>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(a) => AsyncWrite::poll_write(a, cx, buf),
|
||||
EitherOutputProj::Second(b) => AsyncWrite::poll_write(b, cx, buf),
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context, bufs: &[IoSlice])
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>])
|
||||
-> Poll<Result<usize, IoError>>
|
||||
{
|
||||
match self.project() {
|
||||
@ -112,14 +112,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), IoError>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), IoError>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(a) => AsyncWrite::poll_flush(a, cx),
|
||||
EitherOutputProj::Second(b) => AsyncWrite::poll_flush(b, cx),
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), IoError>> {
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), IoError>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(a) => AsyncWrite::poll_close(a, cx),
|
||||
EitherOutputProj::Second(b) => AsyncWrite::poll_close(b, cx),
|
||||
@ -134,7 +134,7 @@ where
|
||||
{
|
||||
type Item = Result<I, EitherError<A::Error, B::Error>>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(a) => TryStream::try_poll_next(a, cx)
|
||||
.map(|v| v.map(|r| r.map_err(EitherError::A))),
|
||||
@ -151,7 +151,7 @@ where
|
||||
{
|
||||
type Error = EitherError<A::Error, B::Error>;
|
||||
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(a) => Sink::poll_ready(a, cx).map_err(EitherError::A),
|
||||
EitherOutputProj::Second(b) => Sink::poll_ready(b, cx).map_err(EitherError::B),
|
||||
@ -165,14 +165,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(a) => Sink::poll_flush(a, cx).map_err(EitherError::A),
|
||||
EitherOutputProj::Second(b) => Sink::poll_flush(b, cx).map_err(EitherError::B),
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
match self.project() {
|
||||
EitherOutputProj::First(a) => Sink::poll_close(a, cx).map_err(EitherError::A),
|
||||
EitherOutputProj::Second(b) => Sink::poll_close(b, cx).map_err(EitherError::B),
|
||||
@ -189,7 +189,7 @@ where
|
||||
type OutboundSubstream = EitherOutbound<A, B>;
|
||||
type Error = IoError;
|
||||
|
||||
fn poll_event(&self, cx: &mut Context) -> Poll<Result<StreamMuxerEvent<Self::Substream>, Self::Error>> {
|
||||
fn poll_event(&self, cx: &mut Context<'_>) -> Poll<Result<StreamMuxerEvent<Self::Substream>, Self::Error>> {
|
||||
match self {
|
||||
EitherOutput::First(inner) => inner.poll_event(cx).map(|result| {
|
||||
result.map_err(|e| e.into()).map(|event| {
|
||||
@ -219,7 +219,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_outbound(&self, cx: &mut Context, substream: &mut Self::OutboundSubstream) -> Poll<Result<Self::Substream, Self::Error>> {
|
||||
fn poll_outbound(&self, cx: &mut Context<'_>, substream: &mut Self::OutboundSubstream) -> Poll<Result<Self::Substream, Self::Error>> {
|
||||
match (self, substream) {
|
||||
(EitherOutput::First(ref inner), EitherOutbound::A(ref mut substream)) => {
|
||||
inner.poll_outbound(cx, substream).map(|p| p.map(EitherOutput::First)).map_err(|e| e.into())
|
||||
@ -248,7 +248,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn read_substream(&self, cx: &mut Context, sub: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
fn read_substream(&self, cx: &mut Context<'_>, sub: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
match (self, sub) {
|
||||
(EitherOutput::First(ref inner), EitherOutput::First(ref mut sub)) => {
|
||||
inner.read_substream(cx, sub, buf).map_err(|e| e.into())
|
||||
@ -260,7 +260,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn write_substream(&self, cx: &mut Context, sub: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
fn write_substream(&self, cx: &mut Context<'_>, sub: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
match (self, sub) {
|
||||
(EitherOutput::First(ref inner), EitherOutput::First(ref mut sub)) => {
|
||||
inner.write_substream(cx, sub, buf).map_err(|e| e.into())
|
||||
@ -272,7 +272,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn flush_substream(&self, cx: &mut Context, sub: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
fn flush_substream(&self, cx: &mut Context<'_>, sub: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
match (self, sub) {
|
||||
(EitherOutput::First(ref inner), EitherOutput::First(ref mut sub)) => {
|
||||
inner.flush_substream(cx, sub).map_err(|e| e.into())
|
||||
@ -284,7 +284,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn shutdown_substream(&self, cx: &mut Context, sub: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
fn shutdown_substream(&self, cx: &mut Context<'_>, sub: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
match (self, sub) {
|
||||
(EitherOutput::First(ref inner), EitherOutput::First(ref mut sub)) => {
|
||||
inner.shutdown_substream(cx, sub).map_err(|e| e.into())
|
||||
@ -313,14 +313,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn close(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
match self {
|
||||
EitherOutput::First(inner) => inner.close(cx).map_err(|e| e.into()),
|
||||
EitherOutput::Second(inner) => inner.close(cx).map_err(|e| e.into()),
|
||||
}
|
||||
}
|
||||
|
||||
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
match self {
|
||||
EitherOutput::First(inner) => inner.flush_all(cx).map_err(|e| e.into()),
|
||||
EitherOutput::Second(inner) => inner.flush_all(cx).map_err(|e| e.into()),
|
||||
@ -351,7 +351,7 @@ where
|
||||
{
|
||||
type Item = Result<ListenerEvent<EitherFuture<AInner, BInner>, EitherError<AError, BError>>, EitherError<AError, BError>>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
match self.project() {
|
||||
EitherListenStreamProj::First(a) => match TryStream::try_poll_next(a, cx) {
|
||||
Poll::Pending => Poll::Pending,
|
||||
@ -385,7 +385,7 @@ where
|
||||
{
|
||||
type Output = Result<EitherOutput<AInner, BInner>, EitherError<AFuture::Error, BFuture::Error>>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
match self.project() {
|
||||
EitherFutureProj::First(a) => TryFuture::try_poll(a, cx)
|
||||
.map_ok(EitherOutput::First).map_err(EitherError::A),
|
||||
@ -407,7 +407,7 @@ where
|
||||
{
|
||||
type Output = Result<EitherOutput<AItem, BItem>, EitherError<AError, BError>>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
match self.project() {
|
||||
EitherFuture2Proj::A(a) => TryFuture::try_poll(a, cx)
|
||||
.map_ok(EitherOutput::First).map_err(EitherError::A),
|
||||
|
@ -41,7 +41,7 @@ impl DecodingError {
|
||||
}
|
||||
|
||||
impl fmt::Display for DecodingError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Key decoding error: {}", self.msg)
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,7 @@ impl SigningError {
|
||||
}
|
||||
|
||||
impl fmt::Display for SigningError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Key signing error: {}", self.msg)
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ mod tests {
|
||||
struct SomeKeypair(Keypair);
|
||||
|
||||
impl fmt::Debug for SomeKeypair {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "SomeKeypair")
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ pub trait StreamMuxer {
|
||||
/// Only the latest task that was used to call this method may be notified.
|
||||
///
|
||||
/// An error can be generated if the connection has been closed.
|
||||
fn poll_event(&self, cx: &mut Context) -> Poll<Result<StreamMuxerEvent<Self::Substream>, Self::Error>>;
|
||||
fn poll_event(&self, cx: &mut Context<'_>) -> Poll<Result<StreamMuxerEvent<Self::Substream>, Self::Error>>;
|
||||
|
||||
/// Opens a new outgoing substream, and produces the equivalent to a future that will be
|
||||
/// resolved when it becomes available.
|
||||
@ -110,7 +110,7 @@ pub trait StreamMuxer {
|
||||
///
|
||||
/// May panic or produce an undefined result if an earlier polling of the same substream
|
||||
/// returned `Ready` or `Err`.
|
||||
fn poll_outbound(&self, cx: &mut Context, s: &mut Self::OutboundSubstream)
|
||||
fn poll_outbound(&self, cx: &mut Context<'_>, s: &mut Self::OutboundSubstream)
|
||||
-> Poll<Result<Self::Substream, Self::Error>>;
|
||||
|
||||
/// Destroys an outbound substream future. Use this after the outbound substream has finished,
|
||||
@ -128,7 +128,7 @@ pub trait StreamMuxer {
|
||||
///
|
||||
/// An error can be generated if the connection has been closed, or if a protocol misbehaviour
|
||||
/// happened.
|
||||
fn read_substream(&self, cx: &mut Context, s: &mut Self::Substream, buf: &mut [u8])
|
||||
fn read_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream, buf: &mut [u8])
|
||||
-> Poll<Result<usize, Self::Error>>;
|
||||
|
||||
/// Write data to a substream. The behaviour is the same as `futures::AsyncWrite::poll_write`.
|
||||
@ -142,7 +142,7 @@ pub trait StreamMuxer {
|
||||
///
|
||||
/// It is incorrect to call this method on a substream if you called `shutdown_substream` on
|
||||
/// this substream earlier.
|
||||
fn write_substream(&self, cx: &mut Context, s: &mut Self::Substream, buf: &[u8])
|
||||
fn write_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream, buf: &[u8])
|
||||
-> Poll<Result<usize, Self::Error>>;
|
||||
|
||||
/// Flushes a substream. The behaviour is the same as `futures::AsyncWrite::poll_flush`.
|
||||
@ -155,7 +155,7 @@ pub trait StreamMuxer {
|
||||
/// call this method may be notified.
|
||||
///
|
||||
/// > **Note**: This method may be implemented as a call to `flush_all`.
|
||||
fn flush_substream(&self, cx: &mut Context, s: &mut Self::Substream)
|
||||
fn flush_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream)
|
||||
-> Poll<Result<(), Self::Error>>;
|
||||
|
||||
/// Attempts to shut down the writing side of a substream. The behaviour is similar to
|
||||
@ -169,7 +169,7 @@ pub trait StreamMuxer {
|
||||
///
|
||||
/// An error can be generated if the connection has been closed, or if a protocol misbehaviour
|
||||
/// happened.
|
||||
fn shutdown_substream(&self, cx: &mut Context, s: &mut Self::Substream)
|
||||
fn shutdown_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream)
|
||||
-> Poll<Result<(), Self::Error>>;
|
||||
|
||||
/// Destroys a substream.
|
||||
@ -198,14 +198,14 @@ pub trait StreamMuxer {
|
||||
/// > that the remote is properly informed of the shutdown. However, apart from
|
||||
/// > properly informing the remote, there is no difference between this and
|
||||
/// > immediately dropping the muxer.
|
||||
fn close(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>>;
|
||||
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
|
||||
|
||||
/// Flush this `StreamMuxer`.
|
||||
///
|
||||
/// This drains any write buffers of substreams and delivers any pending shutdown notifications
|
||||
/// due to `shutdown_substream` or `close`. One may thus shutdown groups of substreams
|
||||
/// followed by a final `flush_all` instead of having to do `flush_substream` for each.
|
||||
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>>;
|
||||
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
|
||||
}
|
||||
|
||||
/// Event about a connection, reported by an implementation of [`StreamMuxer`].
|
||||
@ -280,7 +280,7 @@ where
|
||||
{
|
||||
type Output = Result<SubstreamRef<P>, <P::Target as StreamMuxer>::Error>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
match Future::poll(Pin::new(&mut self.inner), cx) {
|
||||
Poll::Ready(Ok(substream)) => {
|
||||
let out = substream_from_ref(self.inner.muxer.clone(), substream);
|
||||
@ -329,7 +329,7 @@ where
|
||||
{
|
||||
type Output = Result<<P::Target as StreamMuxer>::Substream, <P::Target as StreamMuxer>::Error>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
// We use a `this` because the compiler isn't smart enough to allow mutably borrowing
|
||||
// multiple different fields from the `Pin` at the same time.
|
||||
let this = &mut *self;
|
||||
@ -405,7 +405,7 @@ where
|
||||
P: Deref,
|
||||
P::Target: StreamMuxer,
|
||||
{
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
// We use a `this` because the compiler isn't smart enough to allow mutably borrowing
|
||||
// multiple different fields from the `Pin` at the same time.
|
||||
let this = &mut *self;
|
||||
@ -420,7 +420,7 @@ where
|
||||
P: Deref,
|
||||
P::Target: StreamMuxer,
|
||||
{
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
// We use a `this` because the compiler isn't smart enough to allow mutably borrowing
|
||||
// multiple different fields from the `Pin` at the same time.
|
||||
let this = &mut *self;
|
||||
@ -429,7 +429,7 @@ where
|
||||
this.muxer.write_substream(cx, s, buf).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
// We use a `this` because the compiler isn't smart enough to allow mutably borrowing
|
||||
// multiple different fields from the `Pin` at the same time.
|
||||
let this = &mut *self;
|
||||
@ -458,7 +458,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
// We use a `this` because the compiler isn't smart enough to allow mutably borrowing
|
||||
// multiple different fields from the `Pin` at the same time.
|
||||
let this = &mut *self;
|
||||
@ -511,7 +511,7 @@ impl StreamMuxer for StreamMuxerBox {
|
||||
type Error = io::Error;
|
||||
|
||||
#[inline]
|
||||
fn poll_event(&self, cx: &mut Context) -> Poll<Result<StreamMuxerEvent<Self::Substream>, Self::Error>> {
|
||||
fn poll_event(&self, cx: &mut Context<'_>) -> Poll<Result<StreamMuxerEvent<Self::Substream>, Self::Error>> {
|
||||
self.inner.poll_event(cx)
|
||||
}
|
||||
|
||||
@ -521,7 +521,7 @@ impl StreamMuxer for StreamMuxerBox {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn poll_outbound(&self, cx: &mut Context, s: &mut Self::OutboundSubstream) -> Poll<Result<Self::Substream, Self::Error>> {
|
||||
fn poll_outbound(&self, cx: &mut Context<'_>, s: &mut Self::OutboundSubstream) -> Poll<Result<Self::Substream, Self::Error>> {
|
||||
self.inner.poll_outbound(cx, s)
|
||||
}
|
||||
|
||||
@ -531,22 +531,22 @@ impl StreamMuxer for StreamMuxerBox {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_substream(&self, cx: &mut Context, s: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
fn read_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
self.inner.read_substream(cx, s, buf)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write_substream(&self, cx: &mut Context, s: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
fn write_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
self.inner.write_substream(cx, s, buf)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn flush_substream(&self, cx: &mut Context, s: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
fn flush_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
self.inner.flush_substream(cx, s)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn shutdown_substream(&self, cx: &mut Context, s: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
fn shutdown_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
self.inner.shutdown_substream(cx, s)
|
||||
}
|
||||
|
||||
@ -556,12 +556,12 @@ impl StreamMuxer for StreamMuxerBox {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn close(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
self.inner.close(cx)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
self.inner.flush_all(cx)
|
||||
}
|
||||
}
|
||||
@ -583,7 +583,7 @@ where
|
||||
type Error = io::Error;
|
||||
|
||||
#[inline]
|
||||
fn poll_event(&self, cx: &mut Context) -> Poll<Result<StreamMuxerEvent<Self::Substream>, Self::Error>> {
|
||||
fn poll_event(&self, cx: &mut Context<'_>) -> Poll<Result<StreamMuxerEvent<Self::Substream>, Self::Error>> {
|
||||
let substream = match self.inner.poll_event(cx) {
|
||||
Poll::Pending => return Poll::Pending,
|
||||
Poll::Ready(Ok(StreamMuxerEvent::AddressChange(a))) =>
|
||||
@ -608,7 +608,7 @@ where
|
||||
#[inline]
|
||||
fn poll_outbound(
|
||||
&self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
substream: &mut Self::OutboundSubstream,
|
||||
) -> Poll<Result<Self::Substream, Self::Error>> {
|
||||
let mut list = self.outbound.lock();
|
||||
@ -629,25 +629,25 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_substream(&self, cx: &mut Context, s: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
fn read_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
let mut list = self.substreams.lock();
|
||||
self.inner.read_substream(cx, list.get_mut(s).unwrap(), buf).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write_substream(&self, cx: &mut Context, s: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
fn write_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, Self::Error>> {
|
||||
let mut list = self.substreams.lock();
|
||||
self.inner.write_substream(cx, list.get_mut(s).unwrap(), buf).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn flush_substream(&self, cx: &mut Context, s: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
fn flush_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
let mut list = self.substreams.lock();
|
||||
self.inner.flush_substream(cx, list.get_mut(s).unwrap()).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn shutdown_substream(&self, cx: &mut Context, s: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
fn shutdown_substream(&self, cx: &mut Context<'_>, s: &mut Self::Substream) -> Poll<Result<(), Self::Error>> {
|
||||
let mut list = self.substreams.lock();
|
||||
self.inner.shutdown_substream(cx, list.get_mut(s).unwrap()).map_err(|e| e.into())
|
||||
}
|
||||
@ -659,12 +659,12 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn close(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
self.inner.close(cx).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
self.inner.flush_all(cx).map_err(|e| e.into())
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ where
|
||||
type OutboundSubstream = OutboundSubstream;
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll_event(&self, _: &mut Context) -> Poll<Result<StreamMuxerEvent<Self::Substream>, io::Error>> {
|
||||
fn poll_event(&self, _: &mut Context<'_>) -> Poll<Result<StreamMuxerEvent<Self::Substream>, io::Error>> {
|
||||
match self.endpoint {
|
||||
Endpoint::Dialer => return Poll::Pending,
|
||||
Endpoint::Listener => {}
|
||||
@ -82,7 +82,7 @@ where
|
||||
OutboundSubstream {}
|
||||
}
|
||||
|
||||
fn poll_outbound(&self, _: &mut Context, _: &mut Self::OutboundSubstream) -> Poll<Result<Self::Substream, io::Error>> {
|
||||
fn poll_outbound(&self, _: &mut Context<'_>, _: &mut Self::OutboundSubstream) -> Poll<Result<Self::Substream, io::Error>> {
|
||||
match self.endpoint {
|
||||
Endpoint::Listener => return Poll::Pending,
|
||||
Endpoint::Dialer => {}
|
||||
@ -98,31 +98,31 @@ where
|
||||
fn destroy_outbound(&self, _: Self::OutboundSubstream) {
|
||||
}
|
||||
|
||||
fn read_substream(&self, cx: &mut Context, _: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn read_substream(&self, cx: &mut Context<'_>, _: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
AsyncRead::poll_read(Pin::new(&mut *self.inner.lock()), cx, buf)
|
||||
}
|
||||
|
||||
fn write_substream(&self, cx: &mut Context, _: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn write_substream(&self, cx: &mut Context<'_>, _: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
AsyncWrite::poll_write(Pin::new(&mut *self.inner.lock()), cx, buf)
|
||||
}
|
||||
|
||||
fn flush_substream(&self, cx: &mut Context, _: &mut Self::Substream) -> Poll<Result<(), io::Error>> {
|
||||
fn flush_substream(&self, cx: &mut Context<'_>, _: &mut Self::Substream) -> Poll<Result<(), io::Error>> {
|
||||
AsyncWrite::poll_flush(Pin::new(&mut *self.inner.lock()), cx)
|
||||
}
|
||||
|
||||
fn shutdown_substream(&self, cx: &mut Context, _: &mut Self::Substream) -> Poll<Result<(), io::Error>> {
|
||||
fn shutdown_substream(&self, cx: &mut Context<'_>, _: &mut Self::Substream) -> Poll<Result<(), io::Error>> {
|
||||
AsyncWrite::poll_close(Pin::new(&mut *self.inner.lock()), cx)
|
||||
}
|
||||
|
||||
fn destroy_substream(&self, _: Self::Substream) {
|
||||
}
|
||||
|
||||
fn close(&self, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
// The `StreamMuxer` trait requires that `close()` implies `flush_all()`.
|
||||
self.flush_all(cx)
|
||||
}
|
||||
|
||||
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
AsyncWrite::poll_flush(Pin::new(&mut *self.inner.lock()), cx)
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ where
|
||||
}
|
||||
|
||||
/// Provides an API similar to `Stream`, except that it cannot error.
|
||||
pub fn poll<'a>(&'a mut self, cx: &mut Context) -> Poll<NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler, TConnInfo, TPeerId>>
|
||||
pub fn poll<'a>(&'a mut self, cx: &mut Context<'_>) -> Poll<NetworkEvent<'a, TTrans, TInEvent, TOutEvent, THandler, TConnInfo, TPeerId>>
|
||||
where
|
||||
TTrans: Transport<Output = (TConnInfo, TMuxer)>,
|
||||
TTrans::Error: Send + 'static,
|
||||
|
@ -94,7 +94,7 @@ where
|
||||
EitherError<TTransErr, TMapOut::Error>
|
||||
>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let this = self.project();
|
||||
match TryStream::try_poll_next(this.stream, cx) {
|
||||
Poll::Ready(Some(Ok(event))) => {
|
||||
@ -146,7 +146,7 @@ where
|
||||
{
|
||||
type Output = Result<TMapOut::Ok, EitherError<TFut::Error, TMapOut::Error>>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
loop {
|
||||
let future = match &mut self.inner {
|
||||
Either::Left(future) => {
|
||||
|
@ -42,7 +42,7 @@ impl<TOut> Default for DummyTransport<TOut> {
|
||||
}
|
||||
|
||||
impl<TOut> fmt::Debug for DummyTransport<TOut> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "DummyTransport")
|
||||
}
|
||||
}
|
||||
@ -73,13 +73,13 @@ impl<TOut> Transport for DummyTransport<TOut> {
|
||||
pub struct DummyStream(());
|
||||
|
||||
impl fmt::Debug for DummyStream {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "DummyStream")
|
||||
}
|
||||
}
|
||||
|
||||
impl AsyncRead for DummyStream {
|
||||
fn poll_read(self: Pin<&mut Self>, _: &mut Context, _: &mut [u8])
|
||||
fn poll_read(self: Pin<&mut Self>, _: &mut Context<'_>, _: &mut [u8])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
Poll::Ready(Err(io::ErrorKind::Other.into()))
|
||||
@ -87,19 +87,19 @@ impl AsyncRead for DummyStream {
|
||||
}
|
||||
|
||||
impl AsyncWrite for DummyStream {
|
||||
fn poll_write(self: Pin<&mut Self>, _: &mut Context, _: &[u8])
|
||||
fn poll_write(self: Pin<&mut Self>, _: &mut Context<'_>, _: &[u8])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
Poll::Ready(Err(io::ErrorKind::Other.into()))
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, _: &mut Context)
|
||||
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>)
|
||||
-> Poll<Result<(), io::Error>>
|
||||
{
|
||||
Poll::Ready(Err(io::ErrorKind::Other.into()))
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, _: &mut Context)
|
||||
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>)
|
||||
-> Poll<Result<(), io::Error>>
|
||||
{
|
||||
Poll::Ready(Err(io::ErrorKind::Other.into()))
|
||||
|
@ -74,7 +74,7 @@ where
|
||||
{
|
||||
type Item = Result<ListenerEvent<MapFuture<X, F>, E>, E>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let this = self.project();
|
||||
match TryStream::try_poll_next(this.stream, cx) {
|
||||
Poll::Ready(Some(Ok(event))) => {
|
||||
@ -124,7 +124,7 @@ where
|
||||
{
|
||||
type Output = Result<B, T::Error>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
let item = match TryFuture::try_poll(this.inner, cx) {
|
||||
Poll::Pending => return Poll::Pending,
|
||||
|
@ -82,7 +82,7 @@ where
|
||||
{
|
||||
type Item = Result<ListenerEvent<MapErrListenerUpgrade<T, F>, TErr>, TErr>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let this = self.project();
|
||||
match TryStream::try_poll_next(this.inner, cx) {
|
||||
Poll::Ready(Some(Ok(event))) => {
|
||||
@ -118,7 +118,7 @@ where T: Transport,
|
||||
{
|
||||
type Output = Result<T::Output, TErr>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
match Future::poll(this.inner, cx) {
|
||||
Poll::Ready(Ok(value)) => Poll::Ready(Ok(value)),
|
||||
@ -146,7 +146,7 @@ where
|
||||
{
|
||||
type Output = Result<T::Output, TErr>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
match Future::poll(this.inner, cx) {
|
||||
Poll::Ready(Ok(value)) => Poll::Ready(Ok(value)),
|
||||
|
@ -46,7 +46,7 @@ pub struct DialFuture {
|
||||
impl Future for DialFuture {
|
||||
type Output = Result<Channel<Vec<u8>>, MemoryTransportError>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
match self.sender.poll_ready(cx) {
|
||||
Poll::Pending => return Poll::Pending,
|
||||
Poll::Ready(Ok(())) => {},
|
||||
@ -175,7 +175,7 @@ pub struct Listener {
|
||||
impl Stream for Listener {
|
||||
type Item = Result<ListenerEvent<Ready<Result<Channel<Vec<u8>>, MemoryTransportError>>, MemoryTransportError>, MemoryTransportError>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
if self.tell_listen_addr {
|
||||
self.tell_listen_addr = false;
|
||||
return Poll::Ready(Some(Ok(ListenerEvent::NewAddress(self.addr.clone()))))
|
||||
@ -240,7 +240,7 @@ impl<T> Unpin for Chan<T> {
|
||||
impl<T> Stream for Chan<T> {
|
||||
type Item = Result<T, io::Error>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
match Stream::poll_next(Pin::new(&mut self.incoming), cx) {
|
||||
Poll::Pending => Poll::Pending,
|
||||
Poll::Ready(None) => Poll::Ready(Some(Err(io::ErrorKind::BrokenPipe.into()))),
|
||||
@ -252,7 +252,7 @@ impl<T> Stream for Chan<T> {
|
||||
impl<T> Sink<T> for Chan<T> {
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
self.outgoing.poll_ready(cx)
|
||||
.map(|v| v.map_err(|_| io::ErrorKind::BrokenPipe.into()))
|
||||
}
|
||||
@ -261,11 +261,11 @@ impl<T> Sink<T> for Chan<T> {
|
||||
self.outgoing.start_send(item).map_err(|_| io::ErrorKind::BrokenPipe.into())
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ where
|
||||
{
|
||||
type Item = Result<ListenerEvent<Timeout<O>, TransportTimeoutError<E>>, TransportTimeoutError<E>>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let this = self.project();
|
||||
|
||||
let poll_out = match TryStream::try_poll_next(this.inner, cx) {
|
||||
@ -160,7 +160,7 @@ where
|
||||
{
|
||||
type Output = Result<InnerFut::Ok, TransportTimeoutError<InnerFut::Error>>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
// It is debatable whether we should poll the inner future first or the timer first.
|
||||
// For example, if you start dialing with a timeout of 10 seconds, then after 15 seconds
|
||||
// the dialing succeeds on the wire, then after 20 seconds you poll, then depending on
|
||||
|
@ -194,7 +194,7 @@ where
|
||||
{
|
||||
type Output = <EitherUpgrade<C, U> as Future>::Output;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
Future::poll(this.inner, cx)
|
||||
}
|
||||
@ -223,7 +223,7 @@ where
|
||||
{
|
||||
type Output = Result<(I, M), UpgradeError<E>>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
let m = match ready!(Future::poll(this.upgrade, cx)) {
|
||||
Ok(m) => m,
|
||||
@ -337,7 +337,7 @@ where
|
||||
{
|
||||
type Output = Result<(I, D), TransportUpgradeError<F::Error, U::Error>>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
// We use a `this` variable because the compiler can't mutably borrow multiple times
|
||||
// accross a `Deref`.
|
||||
let this = &mut *self;
|
||||
@ -387,7 +387,7 @@ where
|
||||
{
|
||||
type Item = Result<ListenerEvent<ListenerUpgradeFuture<F, U, I, C>, TransportUpgradeError<E, U::Error>>, TransportUpgradeError<E, U::Error>>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
match ready!(TryStream::try_poll_next(self.stream.as_mut(), cx)) {
|
||||
Some(Ok(event)) => {
|
||||
let event = event
|
||||
@ -430,7 +430,7 @@ where
|
||||
{
|
||||
type Output = Result<(I, D), TransportUpgradeError<F::Error, U::Error>>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
// We use a `this` variable because the compiler can't mutably borrow multiple times
|
||||
// accross a `Deref`.
|
||||
let this = &mut *self;
|
||||
|
@ -105,7 +105,7 @@ where
|
||||
{
|
||||
type Output = Result<U::Output, UpgradeError<U::Error>>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
loop {
|
||||
match mem::replace(&mut self.inner, InboundUpgradeApplyState::Undefined) {
|
||||
InboundUpgradeApplyState::Init { mut future, upgrade } => {
|
||||
@ -181,7 +181,7 @@ where
|
||||
{
|
||||
type Output = Result<U::Output, UpgradeError<U::Error>>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
loop {
|
||||
match mem::replace(&mut self.inner, OutboundUpgradeApplyState::Undefined) {
|
||||
OutboundUpgradeApplyState::Init { mut future, upgrade } => {
|
||||
|
@ -244,7 +244,7 @@ where
|
||||
{
|
||||
type Output = Result<TOut, TInnerFut::Error>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
let item = match TryFuture::try_poll(this.inner, cx) {
|
||||
Poll::Ready(Ok(v)) => v,
|
||||
@ -271,7 +271,7 @@ where
|
||||
{
|
||||
type Output = Result<T::Ok, A>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
match TryFuture::try_poll(this.fut, cx) {
|
||||
Poll::Pending => Poll::Pending,
|
||||
|
@ -32,7 +32,7 @@ impl ConnectionHandler for TestHandler {
|
||||
fn inject_address_change(&mut self, _: &Multiaddr)
|
||||
{}
|
||||
|
||||
fn poll(&mut self, _: &mut Context)
|
||||
fn poll(&mut self, _: &mut Context<'_>)
|
||||
-> Poll<Result<ConnectionHandlerEvent<Self::OutboundOpenInfo, Self::OutEvent>, Self::Error>>
|
||||
{
|
||||
Poll::Ready(Ok(ConnectionHandlerEvent::Custom(())))
|
||||
@ -63,7 +63,7 @@ where
|
||||
{
|
||||
type Output = Result<M, M::Error>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
loop {
|
||||
match std::mem::replace(&mut self.state, CloseMuxerState::Done) {
|
||||
CloseMuxerState::Close(muxer) => {
|
||||
|
@ -147,7 +147,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Kick it off
|
||||
let mut listening = false;
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context| {
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context<'_>| {
|
||||
loop {
|
||||
match stdin.try_poll_next_unpin(cx)? {
|
||||
Poll::Ready(Some(line)) => swarm.floodsub.publish(floodsub_topic.clone(), line.as_bytes()),
|
||||
|
@ -132,7 +132,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Kick it off.
|
||||
let mut listening = false;
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context| {
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context<'_>| {
|
||||
loop {
|
||||
match stdin.try_poll_next_unpin(cx)? {
|
||||
Poll::Ready(Some(line)) => handle_input_line(&mut swarm.kademlia, line),
|
||||
|
@ -118,7 +118,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Kick it off
|
||||
let mut listening = false;
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context| {
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context<'_>| {
|
||||
loop {
|
||||
match stdin.try_poll_next_unpin(cx)? {
|
||||
Poll::Ready(Some(line)) => swarm.publish(&topic, line.as_bytes()),
|
||||
|
@ -278,7 +278,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Kick it off
|
||||
let mut listening = false;
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context| {
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context<'_>| {
|
||||
loop {
|
||||
match stdin.try_poll_next_unpin(cx)? {
|
||||
Poll::Ready(Some(line)) => {
|
||||
|
@ -77,7 +77,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
Swarm::listen_on(&mut swarm, "/ip4/0.0.0.0/tcp/0".parse()?)?;
|
||||
|
||||
let mut listening = false;
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context| {
|
||||
task::block_on(future::poll_fn(move |cx: &mut Context<'_>| {
|
||||
loop {
|
||||
match swarm.poll_next_unpin(cx) {
|
||||
Poll::Ready(Some(event)) => println!("{:?}", event),
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
|
||||
use quote::quote;
|
||||
use proc_macro::TokenStream;
|
||||
|
@ -121,7 +121,7 @@ pub enum FromUrlErr {
|
||||
}
|
||||
|
||||
impl fmt::Display for FromUrlErr {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
FromUrlErr::BadUrl => write!(f, "Bad URL"),
|
||||
FromUrlErr::UnsupportedScheme => write!(f, "Unrecognized URL scheme"),
|
||||
|
@ -143,7 +143,7 @@ impl Multiaddr {
|
||||
/// updated `Protocol` at position `at` will be returned.
|
||||
pub fn replace<'a, F>(&self, at: usize, by: F) -> Option<Multiaddr>
|
||||
where
|
||||
F: FnOnce(&Protocol) -> Option<Protocol<'a>>
|
||||
F: FnOnce(&Protocol<'_>) -> Option<Protocol<'a>>
|
||||
{
|
||||
let mut address = Multiaddr::with_capacity(self.len());
|
||||
let mut fun = Some(by);
|
||||
|
@ -335,7 +335,7 @@ fn append() {
|
||||
assert_eq!(None, i.next())
|
||||
}
|
||||
|
||||
fn replace_ip_addr(a: &Multiaddr, p: Protocol) -> Option<Multiaddr> {
|
||||
fn replace_ip_addr(a: &Multiaddr, p: Protocol<'_>) -> Option<Multiaddr> {
|
||||
a.replace(0, move |x| match x {
|
||||
Protocol::Ip4(_) | Protocol::Ip6(_) => Some(p),
|
||||
_ => None
|
||||
|
@ -163,7 +163,7 @@ where
|
||||
{
|
||||
type Output = Result<(I::Item, Negotiated<R>), NegotiationError>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
|
||||
loop {
|
||||
@ -300,7 +300,7 @@ where
|
||||
{
|
||||
type Output = Result<(I::Item, Negotiated<R>), NegotiationError>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
|
||||
loop {
|
||||
|
@ -110,7 +110,7 @@ impl<R> LengthDelimited<R> {
|
||||
///
|
||||
/// After this method returns `Poll::Ready`, the write buffer of frames
|
||||
/// submitted to the `Sink` is guaranteed to be empty.
|
||||
pub fn poll_write_buffer(self: Pin<&mut Self>, cx: &mut Context)
|
||||
pub fn poll_write_buffer(self: Pin<&mut Self>, cx: &mut Context<'_>)
|
||||
-> Poll<Result<(), io::Error>>
|
||||
where
|
||||
R: AsyncWrite
|
||||
@ -140,7 +140,7 @@ where
|
||||
{
|
||||
type Item = Result<Bytes, io::Error>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let mut this = self.project();
|
||||
|
||||
loop {
|
||||
@ -212,7 +212,7 @@ where
|
||||
{
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
// Use the maximum frame length also as a (soft) upper limit
|
||||
// for the entire write buffer. The actual (hard) limit is thus
|
||||
// implied to be roughly 2 * MAX_FRAME_SIZE.
|
||||
@ -250,7 +250,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
// Write all buffered frame data to the underlying I/O stream.
|
||||
match LengthDelimited::poll_write_buffer(self.as_mut(), cx) {
|
||||
Poll::Ready(Ok(())) => {},
|
||||
@ -265,7 +265,7 @@ where
|
||||
this.inner.poll_flush(cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
// Write all buffered frame data to the underlying I/O stream.
|
||||
match LengthDelimited::poll_write_buffer(self.as_mut(), cx) {
|
||||
Poll::Ready(Ok(())) => {},
|
||||
@ -314,7 +314,7 @@ where
|
||||
{
|
||||
type Item = Result<Bytes, io::Error>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
self.project().inner.poll_next(cx)
|
||||
}
|
||||
}
|
||||
@ -323,7 +323,7 @@ impl<R> AsyncWrite for LengthDelimitedReader<R>
|
||||
where
|
||||
R: AsyncWrite
|
||||
{
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8])
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
// `this` here designates the `LengthDelimited`.
|
||||
@ -340,15 +340,15 @@ where
|
||||
this.project().inner.poll_write(cx, buf)
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
self.project().inner.poll_flush(cx)
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
self.project().inner.poll_close(cx)
|
||||
}
|
||||
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context, bufs: &[IoSlice])
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
// `this` here designates the `LengthDelimited`.
|
||||
|
@ -101,7 +101,7 @@ where
|
||||
{
|
||||
type Output = Result<(N, Negotiated<R>), NegotiationError>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
|
||||
loop {
|
||||
|
@ -57,7 +57,7 @@ where
|
||||
{
|
||||
type Output = Result<Negotiated<TInner>, NegotiationError>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let mut io = self.inner.take().expect("NegotiatedFuture called after completion.");
|
||||
match Negotiated::poll(Pin::new(&mut io), cx) {
|
||||
Poll::Pending => {
|
||||
@ -87,7 +87,7 @@ impl<TInner> Negotiated<TInner> {
|
||||
}
|
||||
|
||||
/// Polls the `Negotiated` for completion.
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), NegotiationError>>
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), NegotiationError>>
|
||||
where
|
||||
TInner: AsyncRead + AsyncWrite + Unpin
|
||||
{
|
||||
@ -191,7 +191,7 @@ impl<TInner> AsyncRead for Negotiated<TInner>
|
||||
where
|
||||
TInner: AsyncRead + AsyncWrite + Unpin
|
||||
{
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8])
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
loop {
|
||||
@ -225,7 +225,7 @@ where
|
||||
}
|
||||
}*/
|
||||
|
||||
fn poll_read_vectored(mut self: Pin<&mut Self>, cx: &mut Context, bufs: &mut [IoSliceMut])
|
||||
fn poll_read_vectored(mut self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
loop {
|
||||
@ -255,7 +255,7 @@ impl<TInner> AsyncWrite for Negotiated<TInner>
|
||||
where
|
||||
TInner: AsyncWrite + AsyncRead + Unpin
|
||||
{
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
match self.project().state.project() {
|
||||
StateProj::Completed { mut io, remaining } => {
|
||||
while !remaining.is_empty() {
|
||||
@ -272,7 +272,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
match self.project().state.project() {
|
||||
StateProj::Completed { mut io, remaining } => {
|
||||
while !remaining.is_empty() {
|
||||
@ -289,7 +289,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
// Ensure all data has been flushed and expected negotiation messages
|
||||
// have been received.
|
||||
ready!(self.as_mut().poll(cx).map_err(Into::<io::Error>::into)?);
|
||||
@ -303,7 +303,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context, bufs: &[IoSlice])
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
match self.project().state.project() {
|
||||
@ -384,13 +384,13 @@ mod tests {
|
||||
struct Capped { buf: Vec<u8>, step: usize }
|
||||
|
||||
impl AsyncRead for Capped {
|
||||
fn poll_read(self: Pin<&mut Self>, _: &mut Context, _: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_read(self: Pin<&mut Self>, _: &mut Context<'_>, _: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsyncWrite for Capped {
|
||||
fn poll_write(mut self: Pin<&mut Self>, _: &mut Context, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_write(mut self: Pin<&mut Self>, _: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
if self.buf.len() + buf.len() > self.buf.capacity() {
|
||||
return Poll::Ready(Err(io::ErrorKind::WriteZero.into()))
|
||||
}
|
||||
@ -399,11 +399,11 @@ mod tests {
|
||||
Poll::Ready(Ok(n))
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ where
|
||||
{
|
||||
type Error = ProtocolError;
|
||||
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
self.project().inner.poll_ready(cx).map_err(From::from)
|
||||
}
|
||||
|
||||
@ -326,11 +326,11 @@ where
|
||||
self.project().inner.start_send(buf.freeze()).map_err(From::from)
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
self.project().inner.poll_flush(cx).map_err(From::from)
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
self.project().inner.poll_close(cx).map_err(From::from)
|
||||
}
|
||||
}
|
||||
@ -341,7 +341,7 @@ where
|
||||
{
|
||||
type Item = Result<Message, ProtocolError>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
match poll_stream(self.project().inner, cx) {
|
||||
Poll::Pending => Poll::Pending,
|
||||
Poll::Ready(None) => Poll::Ready(None),
|
||||
@ -388,7 +388,7 @@ where
|
||||
{
|
||||
type Item = Result<Message, ProtocolError>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
poll_stream(self.project().inner, cx)
|
||||
}
|
||||
}
|
||||
@ -397,24 +397,24 @@ impl<TInner> AsyncWrite for MessageReader<TInner>
|
||||
where
|
||||
TInner: AsyncWrite
|
||||
{
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
self.project().inner.poll_write(cx, buf)
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
self.project().inner.poll_flush(cx)
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
self.project().inner.poll_close(cx)
|
||||
}
|
||||
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context, bufs: &[IoSlice]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>]) -> Poll<Result<usize, io::Error>> {
|
||||
self.project().inner.poll_write_vectored(cx, bufs)
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_stream<S>(stream: Pin<&mut S>, cx: &mut Context) -> Poll<Option<Result<Message, ProtocolError>>>
|
||||
fn poll_stream<S>(stream: Pin<&mut S>, cx: &mut Context<'_>) -> Poll<Option<Result<Message, ProtocolError>>>
|
||||
where
|
||||
S: Stream<Item = Result<Bytes, io::Error>>,
|
||||
{
|
||||
|
@ -245,7 +245,7 @@ impl ArcWake for Notifier {
|
||||
///
|
||||
/// If `Pending` is returned, the waker is kept and notified later, just like with any `Poll`.
|
||||
/// `Ready(Ok())` is almost always returned. An error is returned if the stream is EOF.
|
||||
fn next_match<C, F, O>(inner: &mut MultiplexInner<C>, cx: &mut Context, mut filter: F) -> Poll<Result<O, IoError>>
|
||||
fn next_match<C, F, O>(inner: &mut MultiplexInner<C>, cx: &mut Context<'_>, mut filter: F) -> Poll<Result<O, IoError>>
|
||||
where C: AsyncRead + AsyncWrite + Unpin,
|
||||
F: FnMut(&codec::Elem) -> Option<O>,
|
||||
{
|
||||
@ -324,7 +324,7 @@ where C: AsyncRead + AsyncWrite + Unpin,
|
||||
}
|
||||
|
||||
// Small convenience function that tries to write `elem` to the stream.
|
||||
fn poll_send<C>(inner: &mut MultiplexInner<C>, cx: &mut Context, elem: codec::Elem) -> Poll<Result<(), IoError>>
|
||||
fn poll_send<C>(inner: &mut MultiplexInner<C>, cx: &mut Context<'_>, elem: codec::Elem) -> Poll<Result<(), IoError>>
|
||||
where C: AsyncRead + AsyncWrite + Unpin
|
||||
{
|
||||
ensure_no_error_no_close(inner)?;
|
||||
@ -366,7 +366,7 @@ where C: AsyncRead + AsyncWrite + Unpin
|
||||
type OutboundSubstream = OutboundSubstream;
|
||||
type Error = IoError;
|
||||
|
||||
fn poll_event(&self, cx: &mut Context) -> Poll<Result<StreamMuxerEvent<Self::Substream>, IoError>> {
|
||||
fn poll_event(&self, cx: &mut Context<'_>) -> Poll<Result<StreamMuxerEvent<Self::Substream>, IoError>> {
|
||||
let mut inner = self.inner.lock();
|
||||
|
||||
if inner.opened_substreams.len() >= inner.config.max_substreams {
|
||||
@ -416,7 +416,7 @@ where C: AsyncRead + AsyncWrite + Unpin
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_outbound(&self, cx: &mut Context, substream: &mut Self::OutboundSubstream) -> Poll<Result<Self::Substream, IoError>> {
|
||||
fn poll_outbound(&self, cx: &mut Context<'_>, substream: &mut Self::OutboundSubstream) -> Poll<Result<Self::Substream, IoError>> {
|
||||
loop {
|
||||
let mut inner = self.inner.lock();
|
||||
|
||||
@ -475,7 +475,7 @@ where C: AsyncRead + AsyncWrite + Unpin
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
fn read_substream(&self, cx: &mut Context, substream: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, IoError>> {
|
||||
fn read_substream(&self, cx: &mut Context<'_>, substream: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, IoError>> {
|
||||
loop {
|
||||
// First, transfer from `current_data`.
|
||||
if !substream.current_data.is_empty() {
|
||||
@ -529,7 +529,7 @@ where C: AsyncRead + AsyncWrite + Unpin
|
||||
}
|
||||
}
|
||||
|
||||
fn write_substream(&self, cx: &mut Context, substream: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, IoError>> {
|
||||
fn write_substream(&self, cx: &mut Context<'_>, substream: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, IoError>> {
|
||||
if !substream.local_open {
|
||||
return Poll::Ready(Err(IoErrorKind::BrokenPipe.into()));
|
||||
}
|
||||
@ -551,7 +551,7 @@ where C: AsyncRead + AsyncWrite + Unpin
|
||||
}
|
||||
}
|
||||
|
||||
fn flush_substream(&self, cx: &mut Context, _substream: &mut Self::Substream) -> Poll<Result<(), IoError>> {
|
||||
fn flush_substream(&self, cx: &mut Context<'_>, _substream: &mut Self::Substream) -> Poll<Result<(), IoError>> {
|
||||
let mut inner = self.inner.lock();
|
||||
ensure_no_error_no_close(&mut inner)?;
|
||||
let inner = &mut *inner; // Avoids borrow errors
|
||||
@ -563,7 +563,7 @@ where C: AsyncRead + AsyncWrite + Unpin
|
||||
result
|
||||
}
|
||||
|
||||
fn shutdown_substream(&self, cx: &mut Context, sub: &mut Self::Substream) -> Poll<Result<(), IoError>> {
|
||||
fn shutdown_substream(&self, cx: &mut Context<'_>, sub: &mut Self::Substream) -> Poll<Result<(), IoError>> {
|
||||
if !sub.local_open {
|
||||
return Poll::Ready(Ok(()));
|
||||
}
|
||||
@ -587,7 +587,7 @@ where C: AsyncRead + AsyncWrite + Unpin
|
||||
})
|
||||
}
|
||||
|
||||
fn close(&self, cx: &mut Context) -> Poll<Result<(), IoError>> {
|
||||
fn close(&self, cx: &mut Context<'_>) -> Poll<Result<(), IoError>> {
|
||||
let inner = &mut *self.inner.lock();
|
||||
if inner.is_shutdown {
|
||||
return Poll::Ready(Ok(()))
|
||||
@ -609,7 +609,7 @@ where C: AsyncRead + AsyncWrite + Unpin
|
||||
}
|
||||
}
|
||||
|
||||
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), IoError>> {
|
||||
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), IoError>> {
|
||||
let inner = &mut *self.inner.lock();
|
||||
if inner.is_shutdown {
|
||||
return Poll::Ready(Ok(()))
|
||||
|
@ -37,7 +37,7 @@ pub use yamux::WindowUpdateMode;
|
||||
pub struct Yamux<S>(Mutex<Inner<S>>);
|
||||
|
||||
impl<S> fmt::Debug for Yamux<S> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str("Yamux")
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ where
|
||||
type OutboundSubstream = OpenSubstreamToken;
|
||||
type Error = YamuxError;
|
||||
|
||||
fn poll_event(&self, c: &mut Context) -> Poll<StreamMuxerEvent<Self::Substream>> {
|
||||
fn poll_event(&self, c: &mut Context<'_>) -> Poll<StreamMuxerEvent<Self::Substream>> {
|
||||
let mut inner = self.0.lock();
|
||||
match ready!(inner.incoming.poll_next_unpin(c)) {
|
||||
Some(Ok(s)) => Poll::Ready(Ok(StreamMuxerEvent::InboundSubstream(s))),
|
||||
@ -116,7 +116,7 @@ where
|
||||
OpenSubstreamToken(())
|
||||
}
|
||||
|
||||
fn poll_outbound(&self, c: &mut Context, _: &mut OpenSubstreamToken) -> Poll<Self::Substream> {
|
||||
fn poll_outbound(&self, c: &mut Context<'_>, _: &mut OpenSubstreamToken) -> Poll<Self::Substream> {
|
||||
let mut inner = self.0.lock();
|
||||
Pin::new(&mut inner.control).poll_open_stream(c).map_err(YamuxError)
|
||||
}
|
||||
@ -125,25 +125,25 @@ where
|
||||
self.0.lock().control.abort_open_stream()
|
||||
}
|
||||
|
||||
fn read_substream(&self, c: &mut Context, s: &mut Self::Substream, b: &mut [u8]) -> Poll<usize> {
|
||||
fn read_substream(&self, c: &mut Context<'_>, s: &mut Self::Substream, b: &mut [u8]) -> Poll<usize> {
|
||||
Pin::new(s).poll_read(c, b).map_err(|e| YamuxError(e.into()))
|
||||
}
|
||||
|
||||
fn write_substream(&self, c: &mut Context, s: &mut Self::Substream, b: &[u8]) -> Poll<usize> {
|
||||
fn write_substream(&self, c: &mut Context<'_>, s: &mut Self::Substream, b: &[u8]) -> Poll<usize> {
|
||||
Pin::new(s).poll_write(c, b).map_err(|e| YamuxError(e.into()))
|
||||
}
|
||||
|
||||
fn flush_substream(&self, c: &mut Context, s: &mut Self::Substream) -> Poll<()> {
|
||||
fn flush_substream(&self, c: &mut Context<'_>, s: &mut Self::Substream) -> Poll<()> {
|
||||
Pin::new(s).poll_flush(c).map_err(|e| YamuxError(e.into()))
|
||||
}
|
||||
|
||||
fn shutdown_substream(&self, c: &mut Context, s: &mut Self::Substream) -> Poll<()> {
|
||||
fn shutdown_substream(&self, c: &mut Context<'_>, s: &mut Self::Substream) -> Poll<()> {
|
||||
Pin::new(s).poll_close(c).map_err(|e| YamuxError(e.into()))
|
||||
}
|
||||
|
||||
fn destroy_substream(&self, _: Self::Substream) { }
|
||||
|
||||
fn close(&self, c: &mut Context) -> Poll<()> {
|
||||
fn close(&self, c: &mut Context<'_>) -> Poll<()> {
|
||||
let mut inner = self.0.lock();
|
||||
if let std::task::Poll::Ready(x) = Pin::new(&mut inner.control).poll_close(c) {
|
||||
return Poll::Ready(x.map_err(YamuxError))
|
||||
@ -158,7 +158,7 @@ where
|
||||
Poll::Pending
|
||||
}
|
||||
|
||||
fn flush_all(&self, _: &mut Context) -> Poll<()> {
|
||||
fn flush_all(&self, _: &mut Context<'_>) -> Poll<()> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
@ -290,7 +290,7 @@ pub struct Incoming<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Incoming<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str("Incoming")
|
||||
}
|
||||
}
|
||||
@ -302,7 +302,7 @@ pub struct LocalIncoming<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for LocalIncoming<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str("LocalIncoming")
|
||||
}
|
||||
}
|
||||
@ -310,7 +310,7 @@ impl<T> fmt::Debug for LocalIncoming<T> {
|
||||
impl<T> Stream for Incoming<T> {
|
||||
type Item = Result<yamux::Stream, YamuxError>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> std::task::Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> std::task::Poll<Option<Self::Item>> {
|
||||
self.stream.as_mut().poll_next_unpin(cx)
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ impl<T> Unpin for Incoming<T> {
|
||||
impl<T> Stream for LocalIncoming<T> {
|
||||
type Item = Result<yamux::Stream, YamuxError>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> std::task::Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> std::task::Poll<Option<Self::Item>> {
|
||||
self.stream.as_mut().poll_next_unpin(cx)
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ impl<S> DeflateOutput<S> {
|
||||
|
||||
/// Tries to write the content of `self.write_out` to `self.inner`.
|
||||
/// Returns `Ready(Ok(()))` if `self.write_out` is empty.
|
||||
fn flush_write_out(&mut self, cx: &mut Context) -> Poll<Result<(), io::Error>>
|
||||
fn flush_write_out(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>>
|
||||
where S: AsyncWrite + Unpin
|
||||
{
|
||||
loop {
|
||||
@ -125,7 +125,7 @@ impl<S> DeflateOutput<S> {
|
||||
impl<S> AsyncRead for DeflateOutput<S>
|
||||
where S: AsyncRead + Unpin
|
||||
{
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
// We use a `this` variable because the compiler doesn't allow multiple mutable borrows
|
||||
// across a `Deref`.
|
||||
let this = &mut *self;
|
||||
@ -177,7 +177,7 @@ impl<S> AsyncRead for DeflateOutput<S>
|
||||
impl<S> AsyncWrite for DeflateOutput<S>
|
||||
where S: AsyncWrite + Unpin
|
||||
{
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context, buf: &[u8])
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
// We use a `this` variable because the compiler doesn't allow multiple mutable borrows
|
||||
@ -208,7 +208,7 @@ impl<S> AsyncWrite for DeflateOutput<S>
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
// We use a `this` variable because the compiler doesn't allow multiple mutable borrows
|
||||
// across a `Deref`.
|
||||
let this = &mut *self;
|
||||
@ -231,7 +231,7 @@ impl<S> AsyncWrite for DeflateOutput<S>
|
||||
AsyncWrite::poll_flush(Pin::new(&mut this.inner), cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
// We use a `this` variable because the compiler doesn't allow multiple mutable borrows
|
||||
// across a `Deref`.
|
||||
let this = &mut *self;
|
||||
|
@ -370,7 +370,7 @@ impl NetworkBehaviour for Floodsub {
|
||||
|
||||
fn poll(
|
||||
&mut self,
|
||||
_: &mut Context,
|
||||
_: &mut Context<'_>,
|
||||
_: &mut impl PollParameters,
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
|
@ -1133,7 +1133,7 @@ impl NetworkBehaviour for Gossipsub {
|
||||
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
_: &mut impl PollParameters,
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
|
@ -230,7 +230,7 @@ impl GossipsubConfigBuilder {
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for GossipsubConfig {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut builder = f.debug_struct("GossipsubConfig");
|
||||
let _ = builder.field("protocol_id", &self.protocol_id);
|
||||
let _ = builder.field("history_length", &self.history_length);
|
||||
|
@ -165,7 +165,7 @@ impl ProtocolsHandler for GossipsubHandler {
|
||||
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<
|
||||
ProtocolsHandlerEvent<
|
||||
Self::OutboundProtocol,
|
||||
|
@ -18,7 +18,7 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
extern crate fnv;
|
||||
|
||||
|
||||
use crate::protocol::{GossipsubMessage, MessageId};
|
||||
use crate::topic::TopicHash;
|
||||
|
@ -81,13 +81,13 @@ impl Topic {
|
||||
}
|
||||
|
||||
impl fmt::Display for Topic {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.topic)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for TopicHash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.hash)
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ struct Graph {
|
||||
impl Future for Graph {
|
||||
type Output = (Multiaddr, GossipsubEvent);
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
for (addr, node) in &mut self.nodes {
|
||||
match node.poll_next_unpin(cx) {
|
||||
Poll::Ready(Some(event)) => return Poll::Ready((addr.clone(), event)),
|
||||
|
@ -132,7 +132,7 @@ impl ProtocolsHandler for IdentifyHandler {
|
||||
self.keep_alive
|
||||
}
|
||||
|
||||
fn poll(&mut self, cx: &mut Context) -> Poll<
|
||||
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<
|
||||
ProtocolsHandlerEvent<
|
||||
Self::OutboundProtocol,
|
||||
Self::OutboundOpenInfo,
|
||||
|
@ -167,7 +167,7 @@ impl NetworkBehaviour for Identify {
|
||||
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
|
@ -94,7 +94,7 @@ impl Addresses {
|
||||
}
|
||||
|
||||
impl fmt::Debug for Addresses {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_list()
|
||||
.entries(self.addrs.iter())
|
||||
.finish()
|
||||
|
@ -531,7 +531,7 @@ where
|
||||
|
||||
/// Returns an iterator over all non-empty buckets in the routing table.
|
||||
pub fn kbuckets(&mut self)
|
||||
-> impl Iterator<Item = kbucket::KBucketRef<kbucket::Key<PeerId>, Addresses>>
|
||||
-> impl Iterator<Item = kbucket::KBucketRef<'_, kbucket::Key<PeerId>, Addresses>>
|
||||
{
|
||||
self.kbuckets.iter().filter(|b| !b.is_empty())
|
||||
}
|
||||
@ -540,7 +540,7 @@ where
|
||||
///
|
||||
/// Returns `None` if the given key refers to the local key.
|
||||
pub fn kbucket<K>(&mut self, key: K)
|
||||
-> Option<kbucket::KBucketRef<kbucket::Key<PeerId>, Addresses>>
|
||||
-> Option<kbucket::KBucketRef<'_, kbucket::Key<PeerId>, Addresses>>
|
||||
where
|
||||
K: Borrow<[u8]> + Clone
|
||||
{
|
||||
@ -1693,7 +1693,7 @@ where
|
||||
};
|
||||
}
|
||||
|
||||
fn poll(&mut self, cx: &mut Context, parameters: &mut impl PollParameters) -> Poll<
|
||||
fn poll(&mut self, cx: &mut Context<'_>, parameters: &mut impl PollParameters) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
<KademliaHandler<QueryId> as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent,
|
||||
|
@ -109,7 +109,7 @@ impl<TUserData> SubstreamState<TUserData> {
|
||||
/// Tries to close the substream.
|
||||
///
|
||||
/// If the substream is not ready to be closed, returns it back.
|
||||
fn try_close(&mut self, cx: &mut Context) -> Poll<()> {
|
||||
fn try_close(&mut self, cx: &mut Context<'_>) -> Poll<()> {
|
||||
match self {
|
||||
SubstreamState::OutPendingOpen(_, _)
|
||||
| SubstreamState::OutReportError(_, _) => Poll::Ready(()),
|
||||
@ -612,7 +612,7 @@ where
|
||||
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<
|
||||
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>,
|
||||
> {
|
||||
@ -679,7 +679,7 @@ impl Default for KademliaHandlerConfig {
|
||||
fn advance_substream<TUserData>(
|
||||
state: SubstreamState<TUserData>,
|
||||
upgrade: KademliaProtocolConfig,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> (
|
||||
Option<SubstreamState<TUserData>>,
|
||||
Option<
|
||||
|
@ -107,7 +107,7 @@ impl<T> PeriodicJob<T> {
|
||||
|
||||
/// Returns `true` if the job is currently not running but ready
|
||||
/// to be run, `false` otherwise.
|
||||
fn is_ready(&mut self, cx: &mut Context, now: Instant) -> bool {
|
||||
fn is_ready(&mut self, cx: &mut Context<'_>, now: Instant) -> bool {
|
||||
if let PeriodicJobState::Waiting(delay, deadline) = &mut self.state {
|
||||
if now >= *deadline || !Future::poll(Pin::new(delay), cx).is_pending() {
|
||||
return true
|
||||
@ -190,7 +190,7 @@ impl PutRecordJob {
|
||||
/// Must be called in the context of a task. When `NotReady` is returned,
|
||||
/// the current task is registered to be notified when the job is ready
|
||||
/// to be run.
|
||||
pub fn poll<T>(&mut self, cx: &mut Context, store: &mut T, now: Instant) -> Poll<Record>
|
||||
pub fn poll<T>(&mut self, cx: &mut Context<'_>, store: &mut T, now: Instant) -> Poll<Record>
|
||||
where
|
||||
for<'a> T: RecordStore<'a>
|
||||
{
|
||||
@ -288,7 +288,7 @@ impl AddProviderJob {
|
||||
/// Must be called in the context of a task. When `NotReady` is returned,
|
||||
/// the current task is registered to be notified when the job is ready
|
||||
/// to be run.
|
||||
pub fn poll<T>(&mut self, cx: &mut Context, store: &mut T, now: Instant) -> Poll<ProviderRecord>
|
||||
pub fn poll<T>(&mut self, cx: &mut Context<'_>, store: &mut T, now: Instant) -> Poll<ProviderRecord>
|
||||
where
|
||||
for<'a> T: RecordStore<'a>
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ impl<TInner> QueryPool<TInner> {
|
||||
}
|
||||
|
||||
/// Polls the pool to advance the queries.
|
||||
pub fn poll(&mut self, now: Instant) -> QueryPoolState<TInner> {
|
||||
pub fn poll(&mut self, now: Instant) -> QueryPoolState<'_, TInner> {
|
||||
let mut finished = None;
|
||||
let mut timeout = None;
|
||||
let mut waiting = None;
|
||||
@ -327,7 +327,7 @@ impl<TInner> Query<TInner> {
|
||||
}
|
||||
|
||||
/// Advances the state of the underlying peer iterator.
|
||||
fn next(&mut self, now: Instant) -> PeersIterState {
|
||||
fn next(&mut self, now: Instant) -> PeersIterState<'_> {
|
||||
let state = match &mut self.peer_iter {
|
||||
QueryPeerIter::Closest(iter) => iter.next(now),
|
||||
QueryPeerIter::ClosestDisjoint(iter) => iter.next(now),
|
||||
|
@ -267,7 +267,7 @@ impl ClosestPeersIter {
|
||||
}
|
||||
|
||||
/// Advances the state of the iterator, potentially getting a new peer to contact.
|
||||
pub fn next(&mut self, now: Instant) -> PeersIterState {
|
||||
pub fn next(&mut self, now: Instant) -> PeersIterState<'_> {
|
||||
if let State::Finished = self.state {
|
||||
return PeersIterState::Finished
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ impl ClosestDisjointPeersIter {
|
||||
self.iters.iter().any(|i| i.is_waiting(peer))
|
||||
}
|
||||
|
||||
pub fn next(&mut self, now: Instant) -> PeersIterState {
|
||||
pub fn next(&mut self, now: Instant) -> PeersIterState<'_> {
|
||||
let mut state = None;
|
||||
|
||||
// Ensure querying each iterator at most once.
|
||||
@ -713,7 +713,7 @@ mod tests {
|
||||
struct Graph(HashMap<PeerId, Peer>);
|
||||
|
||||
impl std::fmt::Debug for Graph {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fmt.debug_list().entries(self.0.iter().map(|(id, _)| id)).finish()
|
||||
}
|
||||
}
|
||||
@ -807,7 +807,7 @@ mod tests {
|
||||
}
|
||||
|
||||
impl PeerIterator {
|
||||
fn next(&mut self, now: Instant) -> PeersIterState {
|
||||
fn next(&mut self, now: Instant) -> PeersIterState<'_> {
|
||||
match self {
|
||||
PeerIterator::Disjoint(iter) => iter.next(now),
|
||||
PeerIterator::Closest(iter) => iter.next(now),
|
||||
|
@ -129,7 +129,7 @@ impl FixedPeersIter {
|
||||
self.state == State::Finished
|
||||
}
|
||||
|
||||
pub fn next(&mut self) -> PeersIterState {
|
||||
pub fn next(&mut self) -> PeersIterState<'_> {
|
||||
match &mut self.state {
|
||||
State::Finished => return PeersIterState::Finished,
|
||||
State::Waiting { num_waiting } => {
|
||||
|
@ -64,7 +64,7 @@ pub trait RecordStore<'a> {
|
||||
type ProvidedIter: Iterator<Item = Cow<'a, ProviderRecord>>;
|
||||
|
||||
/// Gets a record from the store, given its key.
|
||||
fn get(&'a self, k: &Key) -> Option<Cow<Record>>;
|
||||
fn get(&'a self, k: &Key) -> Option<Cow<'_, Record>>;
|
||||
|
||||
/// Puts a record into the store.
|
||||
fn put(&'a mut self, r: Record) -> Result<()>;
|
||||
|
@ -106,7 +106,7 @@ impl<'a> RecordStore<'a> for MemoryStore {
|
||||
fn(&'a ProviderRecord) -> Cow<'a, ProviderRecord>
|
||||
>;
|
||||
|
||||
fn get(&'a self, k: &Key) -> Option<Cow<Record>> {
|
||||
fn get(&'a self, k: &Key) -> Option<Cow<'_, Record>> {
|
||||
self.records.get(k).map(Cow::Borrowed)
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ impl NetworkBehaviour for Mdns {
|
||||
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
|
@ -397,7 +397,7 @@ pub struct MdnsResponse {
|
||||
|
||||
impl MdnsResponse {
|
||||
/// Creates a new `MdnsResponse` based on the provided `Packet`.
|
||||
fn new(packet: Packet, from: SocketAddr) -> MdnsResponse {
|
||||
fn new(packet: Packet<'_>, from: SocketAddr) -> MdnsResponse {
|
||||
let peers = packet.answers.iter().filter_map(|record| {
|
||||
if record.name.to_string().as_bytes() != SERVICE_NAME {
|
||||
return None;
|
||||
@ -471,7 +471,7 @@ pub struct MdnsPeer {
|
||||
|
||||
impl MdnsPeer {
|
||||
/// Creates a new `MdnsPeer` based on the provided `Packet`.
|
||||
pub fn new(packet: &Packet, record_value: String, my_peer_id: PeerId, ttl: u32) -> MdnsPeer {
|
||||
pub fn new(packet: &Packet<'_>, record_value: String, my_peer_id: PeerId, ttl: u32) -> MdnsPeer {
|
||||
let addrs = packet
|
||||
.additional
|
||||
.iter()
|
||||
|
@ -62,7 +62,7 @@ impl<T> NoiseOutput<T> {
|
||||
}
|
||||
|
||||
impl<T: AsyncRead + Unpin> AsyncRead for NoiseOutput<T> {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll<io::Result<usize>> {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<io::Result<usize>> {
|
||||
loop {
|
||||
let len = self.recv_buffer.len();
|
||||
let off = self.recv_offset;
|
||||
@ -94,7 +94,7 @@ impl<T: AsyncRead + Unpin> AsyncRead for NoiseOutput<T> {
|
||||
}
|
||||
|
||||
impl<T: AsyncWrite + Unpin> AsyncWrite for NoiseOutput<T> {
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<io::Result<usize>> {
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<io::Result<usize>> {
|
||||
let this = Pin::into_inner(self);
|
||||
let mut io = Pin::new(&mut this.io);
|
||||
let frame_buf = &mut this.send_buffer;
|
||||
@ -118,7 +118,7 @@ impl<T: AsyncWrite + Unpin> AsyncWrite for NoiseOutput<T> {
|
||||
return Poll::Ready(Ok(n))
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||
let this = Pin::into_inner(self);
|
||||
let mut io = Pin::new(&mut this.io);
|
||||
let frame_buf = &mut this.send_buffer;
|
||||
@ -134,7 +134,7 @@ impl<T: AsyncWrite + Unpin> AsyncWrite for NoiseOutput<T> {
|
||||
io.as_mut().poll_flush(cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>>{
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>>{
|
||||
ready!(self.as_mut().poll_flush(cx))?;
|
||||
Pin::new(&mut self.io).poll_close(cx)
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ where
|
||||
{
|
||||
type Item = io::Result<Bytes>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let mut this = Pin::into_inner(self);
|
||||
loop {
|
||||
trace!("read state: {:?}", this.read_state);
|
||||
@ -253,7 +253,7 @@ where
|
||||
{
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
let mut this = Pin::into_inner(self);
|
||||
loop {
|
||||
trace!("write state {:?}", this.write_state);
|
||||
@ -334,12 +334,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
ready!(self.as_mut().poll_ready(cx))?;
|
||||
Pin::new(&mut self.io).poll_flush(cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
ready!(self.as_mut().poll_flush(cx))?;
|
||||
Pin::new(&mut self.io).poll_close(cx)
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ pub enum PingFailure {
|
||||
}
|
||||
|
||||
impl fmt::Display for PingFailure {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
PingFailure::Timeout => f.write_str("Ping timeout"),
|
||||
PingFailure::Other { error } => write!(f, "Ping error: {}", error)
|
||||
@ -221,7 +221,7 @@ impl ProtocolsHandler for PingHandler {
|
||||
}
|
||||
}
|
||||
|
||||
fn poll(&mut self, cx: &mut Context) -> Poll<ProtocolsHandlerEvent<protocol::Ping, (), PingResult, Self::Error>> {
|
||||
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<ProtocolsHandlerEvent<protocol::Ping, (), PingResult, Self::Error>> {
|
||||
if let Some(result) = self.pending_results.pop_back() {
|
||||
if let Ok(PingSuccess::Ping { .. }) = result {
|
||||
self.failures = 0;
|
||||
|
@ -108,7 +108,7 @@ impl NetworkBehaviour for Ping {
|
||||
self.events.push_front(PingEvent { peer, result })
|
||||
}
|
||||
|
||||
fn poll(&mut self, _: &mut Context, _: &mut impl PollParameters)
|
||||
fn poll(&mut self, _: &mut Context<'_>, _: &mut impl PollParameters)
|
||||
-> Poll<NetworkBehaviourAction<Void, PingEvent>>
|
||||
{
|
||||
if let Some(e) = self.events.pop_back() {
|
||||
|
@ -192,7 +192,7 @@ where
|
||||
{
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Sink::poll_ready(Pin::new(&mut self.inner), cx)
|
||||
}
|
||||
|
||||
@ -200,11 +200,11 @@ where
|
||||
Sink::start_send(Pin::new(&mut self.inner), item)
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Sink::poll_flush(Pin::new(&mut self.inner), cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Sink::poll_close(Pin::new(&mut self.inner), cx)
|
||||
}
|
||||
}
|
||||
@ -232,7 +232,7 @@ where
|
||||
}
|
||||
|
||||
impl<S: AsyncRead + AsyncWrite + Unpin> AsyncRead for PlainTextOutput<S> {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8])
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
AsyncRead::poll_read(Pin::new(&mut self.stream), cx, buf)
|
||||
@ -240,19 +240,19 @@ impl<S: AsyncRead + AsyncWrite + Unpin> AsyncRead for PlainTextOutput<S> {
|
||||
}
|
||||
|
||||
impl<S: AsyncRead + AsyncWrite + Unpin> AsyncWrite for PlainTextOutput<S> {
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context, buf: &[u8])
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
AsyncWrite::poll_write(Pin::new(&mut self.stream), cx, buf)
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context)
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>)
|
||||
-> Poll<Result<(), io::Error>>
|
||||
{
|
||||
AsyncWrite::poll_flush(Pin::new(&mut self.stream), cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context)
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>)
|
||||
-> Poll<Result<(), io::Error>>
|
||||
{
|
||||
AsyncWrite::poll_close(Pin::new(&mut self.stream), cx)
|
||||
|
@ -243,7 +243,7 @@ impl<S: AsyncRead + AsyncWrite> PnetOutput<S> {
|
||||
impl<S: AsyncRead + AsyncWrite> AsyncRead for PnetOutput<S> {
|
||||
fn poll_read(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
buf: &mut [u8],
|
||||
) -> Poll<Result<usize, io::Error>> {
|
||||
let this = self.project();
|
||||
@ -260,17 +260,17 @@ impl<S: AsyncRead + AsyncWrite> AsyncRead for PnetOutput<S> {
|
||||
impl<S: AsyncRead + AsyncWrite> AsyncWrite for PnetOutput<S> {
|
||||
fn poll_write(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
buf: &[u8],
|
||||
) -> Poll<Result<usize, io::Error>> {
|
||||
self.project().inner.poll_write(cx, buf)
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
self.project().inner.poll_flush(cx)
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
self.project().inner.poll_close(cx)
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ where
|
||||
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<
|
||||
ProtocolsHandlerEvent<RequestProtocol<TCodec>, RequestId, Self::OutEvent, Self::Error>,
|
||||
> {
|
||||
|
@ -577,7 +577,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll(&mut self, _: &mut Context, _: &mut impl PollParameters)
|
||||
fn poll(&mut self, _: &mut Context<'_>, _: &mut impl PollParameters)
|
||||
-> Poll<NetworkBehaviourAction<
|
||||
RequestProtocol<TCodec>,
|
||||
RequestResponseEvent<TCodec::Request, TCodec::Response>
|
||||
|
@ -66,7 +66,7 @@ where
|
||||
{
|
||||
type Item = Result<Vec<u8>, SecioError>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let this = self.project();
|
||||
|
||||
let frame = match TryStream::try_poll_next(this.raw_stream, cx) {
|
||||
@ -114,7 +114,7 @@ where
|
||||
{
|
||||
type Error = S::Error;
|
||||
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
let this = self.project();
|
||||
Sink::poll_ready(this.raw_stream, cx)
|
||||
}
|
||||
@ -124,12 +124,12 @@ where
|
||||
Sink::start_send(this.raw_stream, item)
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
let this = self.project();
|
||||
Sink::poll_flush(this.raw_stream, cx)
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
let this = self.project();
|
||||
Sink::poll_close(this.raw_stream, cx)
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ where
|
||||
{
|
||||
type Error = S::Error;
|
||||
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
let this = self.project();
|
||||
Sink::poll_ready(this.raw_sink, cx)
|
||||
}
|
||||
@ -69,12 +69,12 @@ where
|
||||
Sink::start_send(this.raw_sink, data_buf)
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
let this = self.project();
|
||||
Sink::poll_flush(this.raw_sink, cx)
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
let this = self.project();
|
||||
Sink::poll_close(this.raw_sink, cx)
|
||||
}
|
||||
@ -86,7 +86,7 @@ where
|
||||
{
|
||||
type Item = S::Item;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let this = self.project();
|
||||
Stream::poll_next(this.raw_sink, cx)
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ pub struct LenPrefixCodec<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for LenPrefixCodec<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str("LenPrefixCodec")
|
||||
}
|
||||
}
|
||||
@ -95,7 +95,7 @@ where
|
||||
{
|
||||
type Item = io::Result<Vec<u8>>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
self.stream.poll_next_unpin(cx)
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ where
|
||||
{
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Pin::new(&mut self.sink).poll_ready(cx)
|
||||
}
|
||||
|
||||
@ -114,11 +114,11 @@ where
|
||||
Pin::new(&mut self.sink).start_send(item)
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Pin::new(&mut self.sink).poll_flush(cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Pin::new(&mut self.sink).poll_close(cx)
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ impl<S> AsyncRead for SecioOutput<S>
|
||||
where
|
||||
S: AsyncRead + AsyncWrite + Unpin + Send + 'static
|
||||
{
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8])
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
AsyncRead::poll_read(Pin::new(&mut self.stream), cx, buf)
|
||||
@ -217,19 +217,19 @@ impl<S> AsyncWrite for SecioOutput<S>
|
||||
where
|
||||
S: AsyncRead + AsyncWrite + Unpin + Send + 'static
|
||||
{
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context, buf: &[u8])
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8])
|
||||
-> Poll<Result<usize, io::Error>>
|
||||
{
|
||||
AsyncWrite::poll_write(Pin::new(&mut self.stream), cx, buf)
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context)
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>)
|
||||
-> Poll<Result<(), io::Error>>
|
||||
{
|
||||
AsyncWrite::poll_flush(Pin::new(&mut self.stream), cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context)
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>)
|
||||
-> Poll<Result<(), io::Error>>
|
||||
{
|
||||
AsyncWrite::poll_close(Pin::new(&mut self.stream), cx)
|
||||
@ -273,7 +273,7 @@ where
|
||||
{
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Sink::poll_ready(Pin::new(&mut self.inner), cx)
|
||||
}
|
||||
|
||||
@ -281,11 +281,11 @@ where
|
||||
Sink::start_send(Pin::new(&mut self.inner), item)
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Sink::poll_flush(Pin::new(&mut self.inner), cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
Sink::poll_close(Pin::new(&mut self.inner), cx)
|
||||
}
|
||||
}
|
||||
@ -296,7 +296,7 @@ where
|
||||
{
|
||||
type Item = Result<Vec<u8>, SecioError>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
Stream::poll_next(Pin::new(&mut self.inner), cx)
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ where
|
||||
{
|
||||
type Item = Result<ListenerEvent<BandwidthFuture<TConn>, TErr>, TErr>;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let this = self.project();
|
||||
|
||||
let event =
|
||||
@ -122,7 +122,7 @@ pub struct BandwidthFuture<TInner> {
|
||||
impl<TInner: TryFuture> Future for BandwidthFuture<TInner> {
|
||||
type Output = Result<BandwidthConnecLogging<TInner::Ok>, TInner::Error>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
let inner = ready!(this.inner.try_poll(cx)?);
|
||||
let logged = BandwidthConnecLogging { inner, sinks: this.sinks.clone() };
|
||||
@ -165,14 +165,14 @@ pub struct BandwidthConnecLogging<TInner> {
|
||||
}
|
||||
|
||||
impl<TInner: AsyncRead> AsyncRead for BandwidthConnecLogging<TInner> {
|
||||
fn poll_read(self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll<io::Result<usize>> {
|
||||
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<io::Result<usize>> {
|
||||
let this = self.project();
|
||||
let num_bytes = ready!(this.inner.poll_read(cx, buf))?;
|
||||
this.sinks.inbound.fetch_add(u64::try_from(num_bytes).unwrap_or(u64::max_value()), Ordering::Relaxed);
|
||||
Poll::Ready(Ok(num_bytes))
|
||||
}
|
||||
|
||||
fn poll_read_vectored(self: Pin<&mut Self>, cx: &mut Context, bufs: &mut [IoSliceMut]) -> Poll<io::Result<usize>> {
|
||||
fn poll_read_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>]) -> Poll<io::Result<usize>> {
|
||||
let this = self.project();
|
||||
let num_bytes = ready!(this.inner.poll_read_vectored(cx, bufs))?;
|
||||
this.sinks.inbound.fetch_add(u64::try_from(num_bytes).unwrap_or(u64::max_value()), Ordering::Relaxed);
|
||||
@ -181,26 +181,26 @@ impl<TInner: AsyncRead> AsyncRead for BandwidthConnecLogging<TInner> {
|
||||
}
|
||||
|
||||
impl<TInner: AsyncWrite> AsyncWrite for BandwidthConnecLogging<TInner> {
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<io::Result<usize>> {
|
||||
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<io::Result<usize>> {
|
||||
let this = self.project();
|
||||
let num_bytes = ready!(this.inner.poll_write(cx, buf))?;
|
||||
this.sinks.outbound.fetch_add(u64::try_from(num_bytes).unwrap_or(u64::max_value()), Ordering::Relaxed);
|
||||
Poll::Ready(Ok(num_bytes))
|
||||
}
|
||||
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context, bufs: &[IoSlice]) -> Poll<io::Result<usize>> {
|
||||
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>]) -> Poll<io::Result<usize>> {
|
||||
let this = self.project();
|
||||
let num_bytes = ready!(this.inner.poll_write_vectored(cx, bufs))?;
|
||||
this.sinks.outbound.fetch_add(u64::try_from(num_bytes).unwrap_or(u64::max_value()), Ordering::Relaxed);
|
||||
Poll::Ready(Ok(num_bytes))
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||
let this = self.project();
|
||||
this.inner.poll_flush(cx)
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
|
||||
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||
let this = self.project();
|
||||
this.inner.poll_close(cx)
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ pub trait NetworkBehaviour: Send + 'static {
|
||||
///
|
||||
/// This API mimics the API of the `Stream` trait. The method may register the current task in
|
||||
/// order to wake it up at a later point in time.
|
||||
fn poll(&mut self, cx: &mut Context, params: &mut impl PollParameters)
|
||||
fn poll(&mut self, cx: &mut Context<'_>, params: &mut impl PollParameters)
|
||||
-> Poll<NetworkBehaviourAction<<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent, Self::OutEvent>>;
|
||||
}
|
||||
|
||||
|
@ -481,7 +481,7 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
/// Internal function used by everything event-related.
|
||||
///
|
||||
/// Polls the `Swarm` for the next event.
|
||||
fn poll_next_event(mut self: Pin<&mut Self>, cx: &mut Context)
|
||||
fn poll_next_event(mut self: Pin<&mut Self>, cx: &mut Context<'_>)
|
||||
-> Poll<SwarmEvent<TBehaviour::OutEvent, THandleErr>>
|
||||
{
|
||||
// We use a `this` variable because the compiler can't mutably borrow multiple times
|
||||
@ -779,7 +779,7 @@ enum PendingNotifyHandler {
|
||||
fn notify_one<'a, TInEvent, TConnInfo, TPeerId>(
|
||||
conn: &mut EstablishedConnection<'a, TInEvent, TConnInfo, TPeerId>,
|
||||
event: TInEvent,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Option<TInEvent>
|
||||
where
|
||||
TPeerId: Eq + std::hash::Hash + Clone,
|
||||
@ -810,7 +810,7 @@ fn notify_any<'a, TTrans, TInEvent, TOutEvent, THandler, TConnInfo, TPeerId>(
|
||||
ids: SmallVec<[ConnectionId; 10]>,
|
||||
peer: &mut ConnectedPeer<'a, TTrans, TInEvent, TOutEvent, THandler, TConnInfo, TPeerId>,
|
||||
event: TInEvent,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Option<(TInEvent, SmallVec<[ConnectionId; 10]>)>
|
||||
where
|
||||
TTrans: Transport,
|
||||
@ -859,7 +859,7 @@ fn notify_all<'a, TTrans, TInEvent, TOutEvent, THandler, TConnInfo, TPeerId>(
|
||||
ids: SmallVec<[ConnectionId; 10]>,
|
||||
peer: &mut ConnectedPeer<'a, TTrans, TInEvent, TOutEvent, THandler, TConnInfo, TPeerId>,
|
||||
event: TInEvent,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Option<(TInEvent, SmallVec<[ConnectionId; 10]>)>
|
||||
where
|
||||
TTrans: Transport,
|
||||
@ -907,7 +907,7 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
{
|
||||
type Item = TBehaviour::OutEvent;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
loop {
|
||||
let event = futures::ready!(ExpandedSwarm::poll_next_event(self.as_mut(), cx));
|
||||
if let SwarmEvent::Behaviour(event) = event {
|
||||
@ -1178,7 +1178,7 @@ impl NetworkBehaviour for DummyBehaviour {
|
||||
fn inject_event(&mut self, _: PeerId, _: ConnectionId,
|
||||
_: <Self::ProtocolsHandler as ProtocolsHandler>::OutEvent) {}
|
||||
|
||||
fn poll(&mut self, _: &mut Context, _: &mut impl PollParameters) ->
|
||||
fn poll(&mut self, _: &mut Context<'_>, _: &mut impl PollParameters) ->
|
||||
Poll<NetworkBehaviourAction<<Self::ProtocolsHandler as
|
||||
ProtocolsHandler>::InEvent, Self::OutEvent>>
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ pub trait ProtocolsHandler: Send + 'static {
|
||||
fn connection_keep_alive(&self) -> KeepAlive;
|
||||
|
||||
/// Should behave like `Stream::poll()`.
|
||||
fn poll(&mut self, cx: &mut Context) -> Poll<
|
||||
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<
|
||||
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>
|
||||
>;
|
||||
|
||||
|
@ -81,7 +81,7 @@ impl ProtocolsHandler for DummyProtocolsHandler {
|
||||
#[inline]
|
||||
fn poll(
|
||||
&mut self,
|
||||
_: &mut Context,
|
||||
_: &mut Context<'_>,
|
||||
) -> Poll<
|
||||
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>,
|
||||
> {
|
||||
|
@ -104,7 +104,7 @@ where
|
||||
#[inline]
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<
|
||||
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>,
|
||||
> {
|
||||
|
@ -100,7 +100,7 @@ where
|
||||
#[inline]
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<
|
||||
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>,
|
||||
> {
|
||||
|
@ -58,7 +58,7 @@ where
|
||||
K: fmt::Debug + Eq + Hash,
|
||||
H: fmt::Debug
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("MultiHandler")
|
||||
.field("handlers", &self.handlers)
|
||||
.finish()
|
||||
@ -154,7 +154,7 @@ where
|
||||
.unwrap_or(KeepAlive::No)
|
||||
}
|
||||
|
||||
fn poll(&mut self, cx: &mut Context)
|
||||
fn poll(&mut self, cx: &mut Context<'_>)
|
||||
-> Poll<ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>>
|
||||
{
|
||||
// Calling `gen_range(0, 0)` (see below) would panic, so we have return early to avoid
|
||||
@ -195,7 +195,7 @@ where
|
||||
K: fmt::Debug + Eq + Hash,
|
||||
H: fmt::Debug
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("IntoMultiHandler")
|
||||
.field("handlers", &self.handlers)
|
||||
.finish()
|
||||
@ -266,7 +266,7 @@ where
|
||||
K: fmt::Debug + Eq + Hash,
|
||||
H: fmt::Debug
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Upgrade")
|
||||
.field("upgrades", &self.upgrades)
|
||||
.finish()
|
||||
@ -369,7 +369,7 @@ impl DuplicateProtonameError {
|
||||
}
|
||||
|
||||
impl fmt::Display for DuplicateProtonameError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if let Ok(s) = std::str::from_utf8(&self.0) {
|
||||
write!(f, "duplicate protocol name: {}", s)
|
||||
} else {
|
||||
|
@ -225,7 +225,7 @@ where
|
||||
self.handler.inject_address_change(new_address);
|
||||
}
|
||||
|
||||
fn poll(&mut self, cx: &mut Context) -> Poll<
|
||||
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<
|
||||
Result<ConnectionHandlerEvent<Self::OutboundOpenInfo, Self::OutEvent>, Self::Error>
|
||||
> {
|
||||
// Continue negotiation of newly-opened substreams on the listening side.
|
||||
|
@ -191,7 +191,7 @@ where
|
||||
|
||||
fn poll(
|
||||
&mut self,
|
||||
_: &mut Context,
|
||||
_: &mut Context<'_>,
|
||||
) -> Poll<
|
||||
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>,
|
||||
> {
|
||||
|
@ -187,7 +187,7 @@ where
|
||||
cmp::max(self.proto1.connection_keep_alive(), self.proto2.connection_keep_alive())
|
||||
}
|
||||
|
||||
fn poll(&mut self, cx: &mut Context) -> Poll<ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>> {
|
||||
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>> {
|
||||
|
||||
match self.proto1.poll(cx) {
|
||||
Poll::Ready(ProtocolsHandlerEvent::Custom(event)) => {
|
||||
|
@ -141,7 +141,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn poll(&mut self, cx: &mut Context, params: &mut impl PollParameters)
|
||||
fn poll(&mut self, cx: &mut Context<'_>, params: &mut impl PollParameters)
|
||||
-> Poll<NetworkBehaviourAction<<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent, Self::OutEvent>>
|
||||
{
|
||||
if let Some(inner) = self.inner.as_mut() {
|
||||
@ -252,7 +252,7 @@ where
|
||||
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<
|
||||
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>
|
||||
> {
|
||||
|
@ -330,22 +330,22 @@ codegen!("tokio", TokioTcpConfig, TokioTcpTransStream, TokioTcpListenStream, app
|
||||
|
||||
#[cfg(feature = "async-std")]
|
||||
impl AsyncRead for TcpTransStream {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
AsyncRead::poll_read(Pin::new(&mut self.inner), cx, buf)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "async-std")]
|
||||
impl AsyncWrite for TcpTransStream {
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
AsyncWrite::poll_write(Pin::new(&mut self.inner), cx, buf)
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
AsyncWrite::poll_flush(Pin::new(&mut self.inner), cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
AsyncWrite::poll_close(Pin::new(&mut self.inner), cx)
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ impl ExtTransport {
|
||||
}
|
||||
|
||||
impl fmt::Debug for ExtTransport {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_tuple("ExtTransport").finish()
|
||||
}
|
||||
}
|
||||
@ -224,7 +224,7 @@ impl fmt::Debug for Dial {
|
||||
impl Future for Dial {
|
||||
type Output = Result<Connection, JsErr>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
match Future::poll(Pin::new(&mut *self.inner), cx) {
|
||||
Poll::Ready(Ok(connec)) => Poll::Ready(Ok(Connection::new(connec.into()))),
|
||||
Poll::Pending => Poll::Pending,
|
||||
@ -253,7 +253,7 @@ impl fmt::Debug for Listen {
|
||||
impl Stream for Listen {
|
||||
type Item = Result<ListenerEvent<Ready<Result<Connection, JsErr>>, JsErr>, JsErr>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
loop {
|
||||
if let Some(ev) = self.pending_events.pop_front() {
|
||||
return Poll::Ready(Some(Ok(ev)));
|
||||
@ -371,7 +371,7 @@ impl fmt::Debug for Connection {
|
||||
}
|
||||
|
||||
impl AsyncRead for Connection {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||
loop {
|
||||
match mem::replace(&mut self.read_state, ConnectionReadState::Finished) {
|
||||
ConnectionReadState::Finished => break Poll::Ready(Err(io::ErrorKind::BrokenPipe.into())),
|
||||
@ -435,7 +435,7 @@ impl AsyncRead for Connection {
|
||||
}
|
||||
|
||||
impl AsyncWrite for Connection {
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||
// Note: as explained in the doc-comments of `Connection`, each call to this function must
|
||||
// map to exactly one call to `self.inner.write()`.
|
||||
|
||||
@ -457,12 +457,12 @@ impl AsyncWrite for Connection {
|
||||
Poll::Ready(Ok(buf.len()))
|
||||
}
|
||||
|
||||
fn poll_flush(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
// There's no flushing mechanism. In the FFI we consider that writing implicitly flushes.
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
|
||||
fn poll_close(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
// Shutting down is considered instantaneous.
|
||||
match self.inner.shutdown() {
|
||||
Ok(()) => Poll::Ready(Ok(())),
|
||||
|
@ -470,7 +470,7 @@ pub enum OutgoingData {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Connection<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str("Connection")
|
||||
}
|
||||
}
|
||||
@ -547,7 +547,7 @@ where
|
||||
{
|
||||
type Item = io::Result<IncomingData>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
let item = ready!(self.receiver.poll_next_unpin(cx));
|
||||
let item = item.map(|result| {
|
||||
result.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
|
||||
@ -562,7 +562,7 @@ where
|
||||
{
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||
Pin::new(&mut self.sender)
|
||||
.poll_ready(cx)
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
|
||||
@ -574,13 +574,13 @@ where
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||
Pin::new(&mut self.sender)
|
||||
.poll_flush(cx)
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||
Pin::new(&mut self.sender)
|
||||
.poll_close(cx)
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
|
||||
|
@ -143,7 +143,7 @@ where
|
||||
{
|
||||
type Item = io::Result<Vec<u8>>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
loop {
|
||||
if let Some(item) = ready!(self.0.try_poll_next_unpin(cx)?) {
|
||||
if item.is_data() {
|
||||
@ -162,7 +162,7 @@ where
|
||||
{
|
||||
type Error = io::Error;
|
||||
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||
Pin::new(&mut self.0).poll_ready(cx)
|
||||
}
|
||||
|
||||
@ -170,11 +170,11 @@ where
|
||||
Pin::new(&mut self.0).start_send(framed::OutgoingData::Binary(item))
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||
Pin::new(&mut self.0).poll_flush(cx)
|
||||
}
|
||||
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
|
||||
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||
Pin::new(&mut self.0).poll_close(cx)
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ pub struct Config {
|
||||
}
|
||||
|
||||
impl fmt::Debug for Config {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str("Config")
|
||||
}
|
||||
}
|
||||
@ -143,7 +143,7 @@ pub enum Error {
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Error::Io(e) => write!(f, "i/o error: {}", e),
|
||||
Error::Tls(e) => write!(f, "tls error: {}", e),
|
||||
|
Reference in New Issue
Block a user