From 7bc61de1c250090a441df9102ff0986bb2154ca3 Mon Sep 17 00:00:00 2001 From: TotallyNot <44345987+TotallyNot@users.noreply.github.com> Date: Tue, 29 Apr 2025 22:46:43 +0200 Subject: [PATCH] feat: simplified lifetime bounds on bulk executor --- Cargo.lock | 6 ++--- torn-api-codegen/Cargo.toml | 2 +- torn-api-codegen/src/model/path.rs | 2 +- torn-api-codegen/src/model/scope.rs | 10 ++++----- torn-api/Cargo.toml | 4 ++-- torn-api/src/executor.rs | 34 ++++++++++++++--------------- torn-key-pool/Cargo.toml | 4 ++-- torn-key-pool/src/lib.rs | 4 ++-- 8 files changed, 32 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8edac2..bd4ac23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2271,7 +2271,7 @@ dependencies = [ [[package]] name = "torn-api" -version = "1.1.0" +version = "1.1.1" dependencies = [ "bon", "bytes", @@ -2291,7 +2291,7 @@ dependencies = [ [[package]] name = "torn-api-codegen" -version = "0.2.0" +version = "0.2.1" dependencies = [ "heck", "indexmap", @@ -2304,7 +2304,7 @@ dependencies = [ [[package]] name = "torn-key-pool" -version = "1.1.0" +version = "1.1.1" dependencies = [ "chrono", "futures", diff --git a/torn-api-codegen/Cargo.toml b/torn-api-codegen/Cargo.toml index aca08b2..4ec4678 100644 --- a/torn-api-codegen/Cargo.toml +++ b/torn-api-codegen/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "torn-api-codegen" authors = ["Pyrit [2111649]"] -version = "0.2.0" +version = "0.2.1" edition = "2021" description = "Contains the v2 torn API model descriptions and codegen for the bindings" license-file = { workspace = true } diff --git a/torn-api-codegen/src/model/path.rs b/torn-api-codegen/src/model/path.rs index 0eef06d..c38686d 100644 --- a/torn-api-codegen/src/model/path.rs +++ b/torn-api-codegen/src/model/path.rs @@ -492,7 +492,7 @@ impl Path { self, ids: I, builder: B - ) -> impl futures::Stream)> + use<'e, E, S, I, B> + ) -> impl futures::Stream)> where I: IntoIterator, S: #builder_mod_path::IsComplete, diff --git a/torn-api-codegen/src/model/scope.rs b/torn-api-codegen/src/model/scope.rs index b8fa7b5..ff64304 100644 --- a/torn-api-codegen/src/model/scope.rs +++ b/torn-api-codegen/src/model/scope.rs @@ -65,21 +65,19 @@ impl Scope { #(#functions)* } - pub struct #bulk_name<'e, E> where - E: crate::executor::BulkExecutor<'e>, + pub struct #bulk_name where + E: crate::executor::BulkExecutor, { executor: E, - marker: std::marker::PhantomData<&'e E>, } - impl<'e, E> #bulk_name<'e, E> + impl #bulk_name where - E: crate::executor::BulkExecutor<'e> + E: crate::executor::BulkExecutor { pub fn new(executor: E) -> Self { Self { executor, - marker: std::marker::PhantomData, } } diff --git a/torn-api/Cargo.toml b/torn-api/Cargo.toml index 5811980..0b613cb 100644 --- a/torn-api/Cargo.toml +++ b/torn-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "torn-api" -version = "1.1.0" +version = "1.1.1" edition = "2021" description = "Auto-generated bindings for the v2 torn api" license-file = { workspace = true } @@ -36,7 +36,7 @@ futures = { version = "0.3", default-features = false, features = [ tokio = { version = "1", features = ["full"] } [build-dependencies] -torn-api-codegen = { path = "../torn-api-codegen", version = "0.2" } +torn-api-codegen = { path = "../torn-api-codegen", version = "0.2.1" } syn = { workspace = true, features = ["parsing"] } proc-macro2 = { workspace = true } prettyplease = "0.2" diff --git a/torn-api/src/executor.rs b/torn-api/src/executor.rs index c3d2486..ba62c79 100644 --- a/torn-api/src/executor.rs +++ b/torn-api/src/executor.rs @@ -56,7 +56,7 @@ pub trait Executor: Sized { } } -pub trait BulkExecutor<'e>: 'e + Sized { +pub trait BulkExecutor: Sized { type Error: From + From + Send; fn execute( @@ -158,46 +158,46 @@ where } #[cfg(feature = "scopes")] -pub trait BulkExecutorExt<'e>: BulkExecutor<'e> + Sized { - fn user_bulk(self) -> BulkUserScope<'e, Self>; +pub trait BulkExecutorExt: BulkExecutor + Sized { + fn user_bulk(self) -> BulkUserScope; - fn faction_bulk(self) -> BulkFactionScope<'e, Self>; + fn faction_bulk(self) -> BulkFactionScope; - fn torn_bulk(self) -> BulkTornScope<'e, Self>; + fn torn_bulk(self) -> BulkTornScope; - fn market_bulk(self) -> BulkMarketScope<'e, Self>; + fn market_bulk(self) -> BulkMarketScope; - fn racing_bulk(self) -> BulkRacingScope<'e, Self>; + fn racing_bulk(self) -> BulkRacingScope; - fn forum_bulk(self) -> BulkForumScope<'e, Self>; + fn forum_bulk(self) -> BulkForumScope; } #[cfg(feature = "scopes")] -impl<'e, T> BulkExecutorExt<'e> for T +impl<'e, T> BulkExecutorExt for T where - T: BulkExecutor<'e> + Sized, + T: BulkExecutor + Sized, { - fn user_bulk(self) -> BulkUserScope<'e, Self> { + fn user_bulk(self) -> BulkUserScope { BulkUserScope::new(self) } - fn faction_bulk(self) -> BulkFactionScope<'e, Self> { + fn faction_bulk(self) -> BulkFactionScope { BulkFactionScope::new(self) } - fn torn_bulk(self) -> BulkTornScope<'e, Self> { + fn torn_bulk(self) -> BulkTornScope { BulkTornScope::new(self) } - fn market_bulk(self) -> BulkMarketScope<'e, Self> { + fn market_bulk(self) -> BulkMarketScope { BulkMarketScope::new(self) } - fn racing_bulk(self) -> BulkRacingScope<'e, Self> { + fn racing_bulk(self) -> BulkRacingScope { BulkRacingScope::new(self) } - fn forum_bulk(self) -> BulkForumScope<'e, Self> { + fn forum_bulk(self) -> BulkForumScope { BulkForumScope::new(self) } } @@ -246,7 +246,7 @@ impl Executor for &ReqwestClient { } } -impl<'e> BulkExecutor<'e> for &'e ReqwestClient { +impl BulkExecutor for &ReqwestClient { type Error = crate::Error; fn execute( diff --git a/torn-key-pool/Cargo.toml b/torn-key-pool/Cargo.toml index 94d87e6..28aad1a 100644 --- a/torn-key-pool/Cargo.toml +++ b/torn-key-pool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "torn-key-pool" -version = "1.1.0" +version = "1.1.1" edition = "2021" authors = ["Pyrit [2111649]"] license-file = { workspace = true } @@ -14,7 +14,7 @@ postgres = ["dep:sqlx", "dep:chrono", "dep:indoc"] tokio-runtime = ["dep:tokio", "dep:rand", "dep:tokio-stream"] [dependencies] -torn-api = { path = "../torn-api", default-features = false, version = "1.0.1" } +torn-api = { path = "../torn-api", default-features = false, version = "1.1.1" } thiserror = "2" sqlx = { version = "0.8", features = [ diff --git a/torn-key-pool/src/lib.rs b/torn-key-pool/src/lib.rs index 991ad54..5f8987d 100644 --- a/torn-key-pool/src/lib.rs +++ b/torn-key-pool/src/lib.rs @@ -560,7 +560,7 @@ where } } -impl<'p, S> BulkExecutor<'p> for KeyPoolExecutor<'p, S> +impl BulkExecutor for KeyPoolExecutor<'_, S> where S: KeyPoolStorage + 'static, { @@ -631,7 +631,7 @@ where } } -impl<'p, S> BulkExecutor<'p> for ThrottledKeyPoolExecutor<'p, S> +impl BulkExecutor for ThrottledKeyPoolExecutor<'_, S> where S: KeyPoolStorage + 'static, {