reqwest_cross

Function fetch_plus

Source
pub fn fetch_plus<FResponseHandler, FNotify, Fut, Ret>(
    req: RequestBuilder,
    response_handler: FResponseHandler,
    ui_notify: FNotify,
) -> Receiver<Ret> 
where FResponseHandler: ResponseHandler<Fut, Ret>, Fut: BoundedFuture<Ret>, Ret: ValidReturn, FNotify: UiCallBack,
Expand description

Wraps the call to fetch with the surrounding boilerplate.

§Example

    let client = reqwest::Client::new();
    let request = client.get("https://httpbin.org/get");
    let handler = |result: Result<reqwest::Response, reqwest::Error>| async {
        result.expect("Expecting Response not Error").status()
    };
    let rx = fetch_plus(request, handler, || {});
    let status = rx.await?; //In actual use case code to prevent blocking use try_recv instead
    assert_eq!(status, 200);