Apologies if the there is an obvious solution to the below but need some help . I am writting a little application that basically takes a URL , does a GET request and then will write out the code to a file.
I am having difficulty converting the header data into a string. here is the specific bit of code :
fn get(uri: &str , path: &Path) -> Result<(Vec), Box> {
let mut res = reqwest::get(uri)?;
let mut body = String::new();
let status = String::from(res.status().to_string());
let headers = String::from(res.headers());
The two errors i am getting are :
error: src\main.rs:45: the trait bound std::string::String:std::convert::From<&reqwest::header::HeaderMap>
is not satisfied
error: src\main.rs:45: the trait std::convert::From<&reqwest::header::HeaderMap>
is not implemented for std::string::String
Since i failed on that , i tried to create a Struct that can hold the above data which looked like this:
struct RequestData {
status : String,
header : &reqwest::header::HeaderMap ,
bodydata : String
}
When i attempt to add the header data to the struct i get the following error:
let RequestData1 = RequestData {
status : status ,
header : headers ,
bodydata : body ,
} ;
error: src\main.rs:14: missing lifetime specifier
error: src\main.rs:14: expected lifetime parameter
I have tried various ways of adding lifetimes but failed miserably ( i'm guessing something to do with the &reqwest:: part of the data type which im not sure how to use )
Any help on solving the above would be great !