pub fn ping_fut(
    request_rx: futures::channel::mpsc::UnboundedReceiver<String>,
    response_tx: futures::channel::mpsc::UnboundedSender<bool>,
) -> impl Future<Output = Result<(), anyhow::Error>> {
    request_rx
        .map(move |url| {
            let ret;
            // unsafe needed as we are calling C code.
            let c_str = CString::new(url).unwrap();
            unsafe {
                ret = c_ping(c_str.as_ptr());
            }

            response_tx.unbounded_send(ret == 0).context("failed to send ping response")
        })
        .try_collect()
}
/// Creates a future which reads URLs from `request_rx`, and sends whether the URL is reachable via
/// ICMP echo requests to `response_tx`.
///
/// TODO(fxbug.dev/65581) The current implementation in C++ is blocking, and is required to be on a
/// separate thread as to not block other logic from running. This should be changed to an
/// implementation in Rust.
Creates a future which reads URLs from `request_rx`, and sends whether the URL is reachable via
ICMP echo requests to `response_tx`.


Creates a future which reads URLs from ` request_rx ` and sends whether the URL is reachable via ICMP echo requests to ` response_tx ` .
pub fn ping_fut(
    request_rx: futures::channel::mpsc::UnboundedReceiver<String>,
    response_tx: futures::channel::mpsc::UnboundedSender<bool>,
) -> impl Future<Output = Result<(), anyhow::Error>> {
    request_rx
        .map(move |url| {
            let ret;
            // unsafe needed as we are calling C code.
            let c_str = CString::new(url).unwrap();
            unsafe {
                ret = c_ping(c_str.as_ptr());
            }
            response_tx.unbounded_send(ret == 0).context("failed to send ping response")
        })
        .try_collect()
}
pub fn ping_fut ( request_rx : futures :: channel :: mpsc :: UnboundedReceiver < String > , response_tx : futures :: channel :: mpsc :: UnboundedSender < bool > , ) -> impl Future < Output = Result < ( ) , anyhow :: Error > > { request_rx . map ( move | url | { let ret ; // unsafe needed as we are calling C code. let c_str = CString :: new ( url ) . unwrap ( ) ; unsafe { ret = c_ping ( c_str . as_ptr ( ) ) ; } response_tx . unbounded_send ( ret == 0 ) . context ( " " ) } ) . try_collect ( ) }
Creates a future which reads URLs from `request_rx`, and sends whether the URL is reachable via
ICMP echo requests to `response_tx`.
Creates a future which reads URLs from ` request_rx ` and sends whether the URL is reachable via ICMP echo requests to ` response_tx ` .
request_rx
futures::channel::mpsc::UnboundedReceiver<String>
response_tx
futures::channel::mpsc::UnboundedSender<bool>
request_rx
futures::channel::mpsc::UnboundedReceiver<String>
response_tx
futures::channel::mpsc::UnboundedSender<bool>