pub async fn read_ndjson<T: DeserializeOwned>(
    response: &mut Response<Body>,
) -> Vec<T> {
    let headers = response.headers();
    assert_eq!(
        crate::CONTENT_TYPE_NDJSON,
        headers.get(http::header::CONTENT_TYPE).expect("missing content-type")
    );
    let body_bytes =
        to_bytes(response.body_mut()).await.expect("error reading body");
    let body_string = String::from_utf8(body_bytes.as_ref().into())
        .expect("response contained non-UTF-8 bytes");

    /*
     * TODO-cleanup: Consider using serde_json::StreamDeserializer or maybe
     * implementing an NDJSON-based Serde type?
     * TODO-correctness: If we don't do that, this should split on (\r?\n)+ to
     * be NDJSON-compatible.
     */
    body_string
        .split('\n')
        .filter(|line| !line.is_empty())
        .map(|line| {
            serde_json::from_str(line)
                .expect("failed to parse server body as expected type")
        })
        .collect::<Vec<T>>()
}
/**
 * Given a Hyper Response whose body is expected to represent newline-separated
 * JSON, each line of which is expected to be parseable via Serde as type T,
 * asynchronously read the body of the response and parse it accordingly,
 * returning a vector of T.
 */
Given a Hyper Response whose body is expected to represent newline-separated
JSON, each line of which is expected to be parseable via Serde as type T,
asynchronously read the body of the response and parse it accordingly,
returning a vector of T.
Given a Hyper Response whose body is expected to represent newline - separated JSON each line of which is expected to be parseable via Serde as type T asynchronously read the body of the response and parse it accordingly returning a vector of T .
pub async fn read_ndjson<T: DeserializeOwned>(
    response: &mut Response<Body>,
) -> Vec<T> {
    let headers = response.headers();
    assert_eq!(
        crate::CONTENT_TYPE_NDJSON,
        headers.get(http::header::CONTENT_TYPE).expect("missing content-type")
    );
    let body_bytes =
        to_bytes(response.body_mut()).await.expect("error reading body");
    let body_string = String::from_utf8(body_bytes.as_ref().into())
        .expect("response contained non-UTF-8 bytes");
    /*
     * TODO-cleanup: Consider using serde_json::StreamDeserializer or maybe
     * implementing an NDJSON-based Serde type?
     * TODO-correctness: If we don't do that, this should split on (\r?\n)+ to
     * be NDJSON-compatible.
     */
    body_string
        .split('\n')
        .filter(|line| !line.is_empty())
        .map(|line| {
            serde_json::from_str(line)
                .expect("failed to parse server body as expected type")
        })
        .collect::<Vec<T>>()
}
pub async fn read_ndjson < T : DeserializeOwned > ( response : & mut Response < Body > , ) -> Vec < T > { let headers = response . headers ( ) ; assert_eq ! ( crate CONTENT_TYPE_NDJSON headers get ( http header CONTENT_TYPE ) expect ( " " ) ) ; let body_bytes = to_bytes ( response . body_mut ( ) ) . await . expect ( " " ) ; let body_string = String :: from_utf8 ( body_bytes . as_ref ( ) . into ( ) ) . expect ( " " ) ; /*
     * TODO-cleanup: Consider using serde_json::StreamDeserializer or maybe
     * implementing an NDJSON-based Serde type?
     * TODO-correctness: If we don't do that, this should split on (\r?\n)+ to
     * be NDJSON-compatible.
     */ body_string . split ( '\n' ) . filter ( | line | ! line . is_empty ( ) ) . map ( | line | { serde_json :: from_str ( line ) . expect ( " " ) } ) . collect :: < Vec < T > > ( ) }
Given a Hyper Response whose body is expected to represent newline-separated
 JSON, each line of which is expected to be parseable via Serde as type T,
 asynchronously read the body of the response and parse it accordingly,
 returning a vector of T.
Given a Hyper Response whose body is expected to represent newline - separated JSON each line of which is expected to be parseable via Serde as type T asynchronously read the body of the response and parse it accordingly returning a vector of T .
response
&mut Response<Body>
response
&mut Response<Body>