// call request method on Java side
call request method on Java side
call request method on Java side
fn do_request<'a>(
    env: &'a JNIEnv<'a>,
    uri: &Uri,
    headers: &HeaderMap,
    method: &str,
    body: Option<JValue>,
) -> Result<JObject<'a>> {
    // create parameter list
    let param_url = create_url_param(&env, uri);
    let param_headers = create_headers_param(&env, headers);
    let mut params = vec![param_url, param_headers];
    if let Some(param_body) = body {
        params.push(param_body);
    };
    // request function signature
    let sig = if body.is_some() {
        "(Ljava/net/URL;Ljava/util/HashMap;[B)Lio/zbox/zboxfs/transport/Response;"
    } else {
        "(Ljava/net/URL;Ljava/util/HashMap;)Lio/zbox/zboxfs/transport/Response;"
    };
    // call request function on Java side
    let ret = env
        .call_static_method(
            "io/zbox/zboxfs/transport/HttpTransport",
            method,
            sig,
            &params,
        )
        .map(|resp_obj| resp_obj.l().unwrap())
        .map_err(Error::from);
    // clear local reference
    env.delete_local_ref(param_url.l().unwrap()).unwrap();
    env.delete_local_ref(param_headers.l().unwrap()).unwrap();
    ret
}
fn do_request < ' a > ( env : & ' a JNIEnv < ' a > , uri : & Uri , headers : & HeaderMap , method : & str , body : Option < JValue > , ) -> Result < JObject < ' a > > { // create parameter list let param_url = create_url_param ( & env , uri ) ; let param_headers = create_headers_param ( & env , headers ) ; let mut params = vec ! [ param_url param_headers ] ; if let Some ( param_body ) = body { params . push ( param_body ) ; } ; // request function signature let sig = if body . is_some ( ) { " " } else { " " } ; // call request function on Java side let ret = env . call_static_method ( " " , method , sig , & params , ) . map ( | resp_obj | resp_obj . l ( ) . unwrap ( ) ) . map_err ( Error :: from ) ; // clear local reference env . delete_local_ref ( param_url . l ( ) . unwrap ( ) ) . unwrap ( ) ; env . delete_local_ref ( param_headers . l ( ) . unwrap ( ) ) . unwrap ( ) ; ret }
call request method on Java side
call request method on Java side
env
&'a JNIEnv<'a>
uri
&Uri
headers
&HeaderMap
method
&str
body
Option<JValue>