feat: added readme and documentation

This commit is contained in:
pyrite 2025-08-07 16:28:00 +02:00
parent daeff053f4
commit 893d620c95
Signed by: pyrite
GPG key ID: 7F1BA9170CD35D15
8 changed files with 179 additions and 26 deletions

View file

@ -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 {}