ftnet 0.1.0

FTNet: FifthTry Network
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
pub const PING: &[u8] = b"ping\n";
pub const PONG: &[u8] = b"pong\n";

pub async fn ping(conn: &iroh::endpoint::Connection) -> eyre::Result<()> {
    let (mut send_stream, mut recv_stream) = conn.open_bi().await?;
    send_stream.write_all(PING).await?;
    send_stream.finish()?;
    let msg = recv_stream.read_to_end(10).await?;
    if msg != PONG {
        return Err(eyre::anyhow!("expected {PONG:?}, got {msg:?}"));
    }
    Ok(())
}