pub fn request_with_retries(
    url: &str,
    retries: usize,
    timeout: Duration
) -> Result<Response, Error>
Expand description

Send a request to the specified URL with retries and a timeout

Arguments

  • url - A string slice that holds the URL to be requested.
  • retries - The number of retries to perform in case of a request error.
  • timeout - The duration after which the request should timeout if it is not successful.

Returns

  • Result<Response, Error> - A Result type that holds the Response object on success or an Error object on failure.

Examples

use std::time::Duration; use weblib::request_with_retries; let url = “https://example.com”; let retries = 3; let timeout = Duration::from_secs(10); match request_with_retries(url, retries, timeout) { Ok(response) => println!(“Response: {:?}”, response), Err(e) => println!(“Error: {:?}”, e), }