added ApiSelectionResponse trait

This commit is contained in:
TotallyNot 2024-04-04 16:48:53 +02:00
parent e93b3529cb
commit dc176a4c60
4 changed files with 13 additions and 3 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "torn-api-macros" name = "torn-api-macros"
version = "0.3.1" version = "0.3.2"
edition = "2021" edition = "2021"
authors = ["Pyrit [2111649]"] authors = ["Pyrit [2111649]"]
license = "MIT" license = "MIT"

View file

@ -153,6 +153,12 @@ fn impl_api_category(ast: &syn::DeriveInput) -> TokenStream {
} }
} }
impl crate::ApiSelectionResponse for Response {
fn into_inner(self) -> crate::ApiResponse {
self.0
}
}
impl crate::ApiSelection for #name { impl crate::ApiSelection for #name {
type Response = Response; type Response = Response;

View file

@ -1,6 +1,6 @@
[package] [package]
name = "torn-api" name = "torn-api"
version = "0.7.1" version = "0.7.2"
edition = "2021" edition = "2021"
rust-version = "1.75.0" rust-version = "1.75.0"
authors = ["Pyrit [2111649]"] authors = ["Pyrit [2111649]"]

View file

@ -111,8 +111,12 @@ impl ApiResponse {
} }
} }
pub trait ApiSelectionResponse: Send + Sync + From<ApiResponse> + 'static {
fn into_inner(self) -> ApiResponse;
}
pub trait ApiSelection: Send + Sync + 'static { pub trait ApiSelection: Send + Sync + 'static {
type Response: From<ApiResponse> + Send + Sync; type Response: ApiSelectionResponse;
fn raw_value(self) -> &'static str; fn raw_value(self) -> &'static str;