use bytes::BufMut;
use http::Method;
use crate::{error::IntoHttpError, response::Response};
pub trait Request: Sized + Clone {
type Response: Response;
const METADATA: Metadata;
fn try_into_http_request<T: Default + BufMut>(
self,
ctx: Context,
) -> Result<http::Request<T>, IntoHttpError>;
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Metadata {
pub endpoint: &'static str,
pub method: Method,
pub auth: AuthRequirement,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
pub enum AuthRequirement {
#[default]
None,
Optional,
Required,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Context<'a> {
pub base_url: &'a str,
pub client_id: &'a str,
pub oauth_token: Option<&'a str>,
}