Function weblib::text

source ·
pub fn text(url: &str) -> Result<String, Box<dyn OtherError>>
Expand description

Fetches the contents of a URL and returns them as a String.

Arguments

  • url - A string slice that holds the URL to fetch.

Returns

This function returns a Result object that holds a String with the contents of the fetched URL, or an error message if the fetch fails.

Examples

let url = "https://httpbin.org/ip";
match weblib::text(url) {
    Ok(resp) => println!("{}", resp),
    Err(e) => panic!("Error: {}", e),
}