#![warn(clippy::todo, clippy::unimplemented)]

mod statuscode;
pub mod parse;
mod request;
mod response;
mod header;

pub use {request::{Request, RequestTarget}, 
    response::{Response}, statuscode::{StatusCode, StatusClass}, header::Header};

use std::fmt::Display;

use parse::ParseError;

pub use uri::Host;

#[derive(Debug, PartialEq)]
pub enum HttpError {
    Parse(ParseError),
}

#[derive(Debug, PartialEq)]
pub enum HttpVersion {
    Http10,
    Http11,
    Http20,
    Http30,
}

impl Display for HttpVersion {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(match self {
            HttpVersion::Http10 => "HTTP/1.0",
            HttpVersion::Http11 => "HTTP/1.1",
            HttpVersion::Http20 => "HTTP/2",
            HttpVersion::Http30 => "HTTP/3",
        })
    }
}

#[derive(Debug, PartialEq)]
pub enum Method {
    Get,
    Head,
    Post,
    Put,
    Delete,
    Connect,
    Options,
    Trace,
    Patch,
}

impl Method {
    pub fn from_bytes(bytes: &[u8]) -> Result<Method, ParseError> {
        todo!()
    }
}

impl Display for Method {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(match self {
            Method::Get => "GET",
            Method::Head => "HEAD",
            Method::Post => "POST",
            Method::Put => "PUT",
            Method::Delete => "DELETE",
            Method::Connect => "CONNECT",
            Method::Options => "OPTIONS",
            Method::Trace => "TRACE",
            Method::Patch => "PATCH",
        })
    }
}