feat: simplified lifetime bounds on bulk executor
This commit is contained in:
parent
c17f93f600
commit
7bc61de1c2
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -2271,7 +2271,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "torn-api"
|
name = "torn-api"
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bon",
|
"bon",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -2291,7 +2291,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "torn-api-codegen"
|
name = "torn-api-codegen"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
@ -2304,7 +2304,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "torn-key-pool"
|
name = "torn-key-pool"
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "torn-api-codegen"
|
name = "torn-api-codegen"
|
||||||
authors = ["Pyrit [2111649]"]
|
authors = ["Pyrit [2111649]"]
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Contains the v2 torn API model descriptions and codegen for the bindings"
|
description = "Contains the v2 torn API model descriptions and codegen for the bindings"
|
||||||
license-file = { workspace = true }
|
license-file = { workspace = true }
|
||||||
|
|
|
@ -492,7 +492,7 @@ impl Path {
|
||||||
self,
|
self,
|
||||||
ids: I,
|
ids: I,
|
||||||
builder: B
|
builder: B
|
||||||
) -> impl futures::Stream<Item = (#disc_ty, Result<#response_ty, E::Error>)> + use<'e, E, S, I, B>
|
) -> impl futures::Stream<Item = (#disc_ty, Result<#response_ty, E::Error>)>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = #disc_ty>,
|
I: IntoIterator<Item = #disc_ty>,
|
||||||
S: #builder_mod_path::IsComplete,
|
S: #builder_mod_path::IsComplete,
|
||||||
|
|
|
@ -65,21 +65,19 @@ impl Scope {
|
||||||
#(#functions)*
|
#(#functions)*
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct #bulk_name<'e, E> where
|
pub struct #bulk_name<E> where
|
||||||
E: crate::executor::BulkExecutor<'e>,
|
E: crate::executor::BulkExecutor,
|
||||||
{
|
{
|
||||||
executor: E,
|
executor: E,
|
||||||
marker: std::marker::PhantomData<&'e E>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'e, E> #bulk_name<'e, E>
|
impl<E> #bulk_name<E>
|
||||||
where
|
where
|
||||||
E: crate::executor::BulkExecutor<'e>
|
E: crate::executor::BulkExecutor
|
||||||
{
|
{
|
||||||
pub fn new(executor: E) -> Self {
|
pub fn new(executor: E) -> Self {
|
||||||
Self {
|
Self {
|
||||||
executor,
|
executor,
|
||||||
marker: std::marker::PhantomData,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "torn-api"
|
name = "torn-api"
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Auto-generated bindings for the v2 torn api"
|
description = "Auto-generated bindings for the v2 torn api"
|
||||||
license-file = { workspace = true }
|
license-file = { workspace = true }
|
||||||
|
@ -36,7 +36,7 @@ futures = { version = "0.3", default-features = false, features = [
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[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"] }
|
syn = { workspace = true, features = ["parsing"] }
|
||||||
proc-macro2 = { workspace = true }
|
proc-macro2 = { workspace = true }
|
||||||
prettyplease = "0.2"
|
prettyplease = "0.2"
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub trait Executor: Sized {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait BulkExecutor<'e>: 'e + Sized {
|
pub trait BulkExecutor: Sized {
|
||||||
type Error: From<serde_json::Error> + From<crate::ApiError> + Send;
|
type Error: From<serde_json::Error> + From<crate::ApiError> + Send;
|
||||||
|
|
||||||
fn execute<R>(
|
fn execute<R>(
|
||||||
|
@ -158,46 +158,46 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scopes")]
|
#[cfg(feature = "scopes")]
|
||||||
pub trait BulkExecutorExt<'e>: BulkExecutor<'e> + Sized {
|
pub trait BulkExecutorExt: BulkExecutor + Sized {
|
||||||
fn user_bulk(self) -> BulkUserScope<'e, Self>;
|
fn user_bulk(self) -> BulkUserScope<Self>;
|
||||||
|
|
||||||
fn faction_bulk(self) -> BulkFactionScope<'e, Self>;
|
fn faction_bulk(self) -> BulkFactionScope<Self>;
|
||||||
|
|
||||||
fn torn_bulk(self) -> BulkTornScope<'e, Self>;
|
fn torn_bulk(self) -> BulkTornScope<Self>;
|
||||||
|
|
||||||
fn market_bulk(self) -> BulkMarketScope<'e, Self>;
|
fn market_bulk(self) -> BulkMarketScope<Self>;
|
||||||
|
|
||||||
fn racing_bulk(self) -> BulkRacingScope<'e, Self>;
|
fn racing_bulk(self) -> BulkRacingScope<Self>;
|
||||||
|
|
||||||
fn forum_bulk(self) -> BulkForumScope<'e, Self>;
|
fn forum_bulk(self) -> BulkForumScope<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "scopes")]
|
#[cfg(feature = "scopes")]
|
||||||
impl<'e, T> BulkExecutorExt<'e> for T
|
impl<'e, T> BulkExecutorExt for T
|
||||||
where
|
where
|
||||||
T: BulkExecutor<'e> + Sized,
|
T: BulkExecutor + Sized,
|
||||||
{
|
{
|
||||||
fn user_bulk(self) -> BulkUserScope<'e, Self> {
|
fn user_bulk(self) -> BulkUserScope<Self> {
|
||||||
BulkUserScope::new(self)
|
BulkUserScope::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn faction_bulk(self) -> BulkFactionScope<'e, Self> {
|
fn faction_bulk(self) -> BulkFactionScope<Self> {
|
||||||
BulkFactionScope::new(self)
|
BulkFactionScope::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn torn_bulk(self) -> BulkTornScope<'e, Self> {
|
fn torn_bulk(self) -> BulkTornScope<Self> {
|
||||||
BulkTornScope::new(self)
|
BulkTornScope::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn market_bulk(self) -> BulkMarketScope<'e, Self> {
|
fn market_bulk(self) -> BulkMarketScope<Self> {
|
||||||
BulkMarketScope::new(self)
|
BulkMarketScope::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn racing_bulk(self) -> BulkRacingScope<'e, Self> {
|
fn racing_bulk(self) -> BulkRacingScope<Self> {
|
||||||
BulkRacingScope::new(self)
|
BulkRacingScope::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn forum_bulk(self) -> BulkForumScope<'e, Self> {
|
fn forum_bulk(self) -> BulkForumScope<Self> {
|
||||||
BulkForumScope::new(self)
|
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;
|
type Error = crate::Error;
|
||||||
|
|
||||||
fn execute<R>(
|
fn execute<R>(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "torn-key-pool"
|
name = "torn-key-pool"
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Pyrit [2111649]"]
|
authors = ["Pyrit [2111649]"]
|
||||||
license-file = { workspace = true }
|
license-file = { workspace = true }
|
||||||
|
@ -14,7 +14,7 @@ postgres = ["dep:sqlx", "dep:chrono", "dep:indoc"]
|
||||||
tokio-runtime = ["dep:tokio", "dep:rand", "dep:tokio-stream"]
|
tokio-runtime = ["dep:tokio", "dep:rand", "dep:tokio-stream"]
|
||||||
|
|
||||||
[dependencies]
|
[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"
|
thiserror = "2"
|
||||||
|
|
||||||
sqlx = { version = "0.8", features = [
|
sqlx = { version = "0.8", features = [
|
||||||
|
|
|
@ -560,7 +560,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'p, S> BulkExecutor<'p> for KeyPoolExecutor<'p, S>
|
impl<S> BulkExecutor for KeyPoolExecutor<'_, S>
|
||||||
where
|
where
|
||||||
S: KeyPoolStorage + 'static,
|
S: KeyPoolStorage + 'static,
|
||||||
{
|
{
|
||||||
|
@ -631,7 +631,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'p, S> BulkExecutor<'p> for ThrottledKeyPoolExecutor<'p, S>
|
impl<S> BulkExecutor for ThrottledKeyPoolExecutor<'_, S>
|
||||||
where
|
where
|
||||||
S: KeyPoolStorage + 'static,
|
S: KeyPoolStorage + 'static,
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue