use super::*;
pub trait GetRequest: Sized {
type Response: Decodable;
type Query: ToQuery;
fn path(&self) -> Cow<'_, str>;
fn query(&self) -> Self::Query;
fn request(self) -> Get<Self> {
self.into()
}
}
impl<T: GetRequest> GetRequest for &T {
type Response = T::Response;
type Query = T::Query;
fn path(&self) -> Cow<'_, str> {
<T as GetRequest>::path(self)
}
fn query(&self) -> Self::Query {
<T as GetRequest>::query(self)
}
}
impl<T: GetRequest> Request for Get<T> {
type Request = ();
type Response = T::Response;
type Query = T::Query;
fn path(&self) -> Cow<'_, str> {
self.inner.path()
}
fn body(&self) -> Self::Request {}
fn query(&self) -> Self::Query {
self.inner.query()
}
fn method(&self) -> Method {
Method::Get
}
}