curl-parser
curl-parser copied to clipboard
Reqwest TryInto doesn't work.
Readme example doesn't work, reqwest feature is enabled even though it's default, as you mentioned.
use anyhow::Result;
use std::convert::TryFrom;
fn main() -> Result<()> {
let input = r#"curl \
-X PATCH \
-d '{"visibility":"private"}' \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user/email/visibility "#;
let parsed = curl_parser::ParsedRequest::try_from(input)?;
println!("{:#?}", parsed);
let req: reqwest::RequestBuilder = parsed.into();
println!("{:#?}", req);
Ok(())
}
error[E0277]: the trait bound `ParsedRequest: TryFrom<&str>` is not satisfied
--> keyflux_curl/src/main.rs:12:18
|
12 | let parsed = curl_parser::ParsedRequest::try_from(input)?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<&str>` is not implemented for `ParsedRequest`, which is required by `ParsedRequest: TryFrom<_>`
|
= note: required for `&str` to implement `Into<ParsedRequest>`
= note: required for `ParsedRequest` to implement `TryFrom<&str>`