Created
December 20, 2019 17:41
-
-
Save nerdalert/3a08814036876b3dd0dbced8ca33e47e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let stream = pinger.and_then(move |pinger| Ok(pinger.chain(ip).stream())); | |
let future = stream.and_then(|stream| { | |
stream.take(1).for_each(|mb_time| { | |
match mb_time { | |
Some(time) => { | |
// I need to capture this data (Duration) and get it back to the main scope | |
println!("Time => {:?}", time); | |
} | |
None => println!("timeout"), | |
} | |
Ok(()) | |
}) | |
}); | |
tokio::run(future.map_err(|err| eprintln!("Error: {}", err))) | |
// I need `time` results in this scope |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment