feat: added readme and documentation
This commit is contained in:
parent
daeff053f4
commit
893d620c95
8 changed files with 179 additions and 26 deletions
|
|
@ -2,11 +2,15 @@ use bytes::Bytes;
|
|||
use http::StatusCode;
|
||||
|
||||
#[cfg(feature = "requests")]
|
||||
/// Auto-generated api requests definitions.
|
||||
pub mod models;
|
||||
|
||||
/// A generic api request description.
|
||||
#[derive(Default)]
|
||||
pub struct ApiRequest {
|
||||
/// The relative path relative to "<https://api.torn.com/v2>".
|
||||
pub path: String,
|
||||
/// All url parameters.
|
||||
pub parameters: Vec<(&'static str, String)>,
|
||||
}
|
||||
|
||||
|
|
@ -28,17 +32,25 @@ impl ApiRequest {
|
|||
}
|
||||
}
|
||||
|
||||
/// A generic api response.
|
||||
pub struct ApiResponse {
|
||||
/// The response body as binary blob.
|
||||
pub body: Option<Bytes>,
|
||||
/// The HTTP response code.
|
||||
pub status: StatusCode,
|
||||
}
|
||||
|
||||
/// Trait for typed api requests
|
||||
pub trait IntoRequest: Send {
|
||||
/// If used in bulk request, the discriminant is used to distinguish the responses. For
|
||||
/// endpoints which have no path parameters this will be `()`.
|
||||
type Discriminant: Send + 'static;
|
||||
/// The response type which shall be deserialised.
|
||||
type Response: for<'de> serde::Deserialize<'de> + Send;
|
||||
fn into_request(self) -> (Self::Discriminant, ApiRequest);
|
||||
}
|
||||
|
||||
/* #[cfg(feature = "requests")]
|
||||
pub(crate) struct WrappedApiRequest<R>
|
||||
where
|
||||
R: IntoRequest,
|
||||
|
|
@ -47,6 +59,7 @@ where
|
|||
request: ApiRequest,
|
||||
}
|
||||
|
||||
#[cfg(feature = "requests")]
|
||||
impl<R> IntoRequest for WrappedApiRequest<R>
|
||||
where
|
||||
R: IntoRequest,
|
||||
|
|
@ -56,7 +69,7 @@ where
|
|||
fn into_request(self) -> (Self::Discriminant, ApiRequest) {
|
||||
(self.discriminant, self.request)
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue