Skip to main content

request_and_handle

Function request_and_handle 

Source
pub async fn request_and_handle<F>(
    session: &str,
    req: &Request,
    auto_spawn: bool,
    on_success: F,
) -> i32
where F: FnOnce(Response) -> Option<i32>,
Expand description

Send a request and dispatch the response through a user-supplied callback.

Handles the Error branch centrally (prints the message and returns the exit code). on_success receives any other response and returns Some(exit_code) to finish or None for an unexpected-response fallback.