dothttp 0.10.0

dothttp is a text-based scriptable HTTP client. It is a fork for dot-http. It is a simple language that resembles the actual HTTP protocol but with additional features to make it practical for someone who builds and tests APIs.
Documentation
use std::future::Future;

use crate::{parser, ClientConfig, Result};

pub mod reqwest;

#[derive(Clone, Copy, Debug)]
pub enum Method {
    Get,
    Post,
    Delete,
    Put,
    Patch,
    Options,
}

#[derive(Clone, Debug)]
pub struct Request {
    pub method: Method,
    pub target: String,
    pub headers: Vec<(String, String)>,
    pub body: Option<String>,
}

#[derive(Clone, Debug)]
pub struct Response {
    pub version: Version,
    pub status_code: u16,
    pub status: String,
    pub headers: Vec<(String, String)>,
    pub body: Option<String>,
}

#[derive(Clone, Copy, Debug)]
pub enum Version {
    Http09,
    Http10,
    Http11,
    Http2,
    Http3,
}

pub trait HttpClient {
    fn create(config: ClientConfig) -> Self
    where
        Self: Sized;

    fn execute(&self, request: &Request) -> impl Future<Output = Result<Response>>;
}

impl From<&parser::Method> for Method {
    fn from(method: &parser::Method) -> Self {
        match method {
            parser::Method::Get(_) => Method::Get,
            parser::Method::Post(_) => Method::Post,
            parser::Method::Delete(_) => Method::Delete,
            parser::Method::Put(_) => Method::Put,
            parser::Method::Patch(_) => Method::Patch,
            parser::Method::Options(_) => Method::Options,
        }
    }
}