Skip to content

Commit

Permalink
poll next
Browse files Browse the repository at this point in the history
  • Loading branch information
eserilev committed Dec 5, 2023
1 parent 1f43a65 commit 288a7a9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions examples/escape-hatch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

Check failure on line 1 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/rust-libp2p/rust-libp2p/examples/escape-hatch/src/lib.rs
use std::{collections::VecDeque, io, task::Poll, time::{Duration, Instant}};
use std::{collections::VecDeque, io, task::Poll, time::{Duration, Instant}, pin::Pin};

Check failure on line 2 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

unused import: `Instant`

Check failure on line 2 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (nightly-2023-09-10)

unused import: `Instant`

Check failure on line 2 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / examples

unused import: `Instant`
use futures::{prelude::*, future::Either};

Check failure on line 3 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

unused imports: `future::Either`, `prelude::*`

Check failure on line 3 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (nightly-2023-09-10)

unused imports: `future::Either`, `prelude::*`

Check failure on line 3 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / examples

unused imports: `future::Either`, `prelude::*`
use libp2p::{PeerId, Stream, StreamProtocol, quic::Connection};

Check failure on line 4 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

unused import: `quic::Connection`

Check failure on line 4 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (nightly-2023-09-10)

unused import: `quic::Connection`

Check failure on line 4 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / examples

unresolved import `libp2p::quic`
use libp2p_core::{Multiaddr, transport::MemoryTransport, Transport};

Check failure on line 5 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

unused imports: `Multiaddr`, `Transport`, `transport::MemoryTransport`

Check failure on line 5 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (nightly-2023-09-10)

unused imports: `Multiaddr`, `Transport`, `transport::MemoryTransport`

Check failure on line 5 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / examples

unused imports: `Multiaddr`, `Transport`, `transport::MemoryTransport`
use rand::{distributions, prelude::*};

Check failure on line 6 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

unused imports: `distributions`, `prelude::*`

Check failure on line 6 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (nightly-2023-09-10)

unused imports: `distributions`, `prelude::*`

Check failure on line 6 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / examples

unused imports: `distributions`, `prelude::*`
use futures_timer::Delay;

Check failure on line 7 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

unused import: `futures_timer::Delay`

Check failure on line 7 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (nightly-2023-09-10)

unused import: `futures_timer::Delay`

Check failure on line 7 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / examples

unused import: `futures_timer::Delay`
use std::task::{Context};
use futures::future::poll_fn;

Check failure on line 9 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

unused import: `futures::future::poll_fn`

Check failure on line 9 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (nightly-2023-09-10)

unused import: `futures::future::poll_fn`

Check failure on line 9 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / examples

unused import: `futures::future::poll_fn`
use tokio::{net::TcpStream, io::AsyncWrite};


pub const PROTOCOL_NAME: StreamProtocol = StreamProtocol::new("/ipfs/ping/1.0.0");

Expand Down Expand Up @@ -38,6 +42,7 @@ pub struct Config {
}

pub struct IncomingStreams {
stream: Option<TcpStream>,
/// Queue of events to yield to the swarm.
events: VecDeque<Event>,
}
Expand All @@ -56,8 +61,19 @@ impl IncomingStreams {
todo!()
}

Check failure on line 62 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/rust-libp2p/rust-libp2p/examples/escape-hatch/src/lib.rs

pub fn poll_next(&mut self) -> Poll<(PeerId, Stream)> {
pub fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<(PeerId, Stream)> {

let ping_message = "Ping\n";

// TODO remove unwrap
let stream_ref = self.stream.as_mut().unwrap();

if let Some(e) = self.events.pop_back() {

Check failure on line 71 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / Compile with MSRV

unused variable: `e`
let result = match Pin::new(stream_ref).poll_write(cx, ping_message.as_bytes()) {
Poll::Ready(Ok(_)) => Poll::Pending,
Poll::Ready(Err(e)) => Poll::Ready(()),
Poll::Pending => Poll::Pending,
};
} else {

Check failure on line 77 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (nightly-2023-09-10)

this `else` branch is empty
}

Expand All @@ -78,6 +94,7 @@ impl Behaviour {
},
Control {},

Check failure on line 95 in examples/escape-hatch/src/lib.rs

View workflow job for this annotation

GitHub Actions / rustfmt

Diff in /home/runner/work/rust-libp2p/rust-libp2p/examples/escape-hatch/src/lib.rs
IncomingStreams {
stream: None,
events: VecDeque::new()
},
)
Expand Down

0 comments on commit 288a7a9

Please sign in to comment.