Skip to content

Commit 63f2ba0

Browse files
authored
feat: added Send marker for builder (#173)
1 parent 41a1698 commit 63f2ba0

17 files changed

+388
-356
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repository = "https://github.com/kilork/keycloak"
1414
rust-version = "1.87"
1515

1616
[features]
17-
default = ["tags-all"]
17+
default = ["tags-all", "resource-builder"]
1818
resource-builder = ["builder", "resource"]
1919
schemars = ["dep:schemars"]
2020
multipart = ["reqwest/multipart"]

examples/openapi.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ fn generate_method_builder(add_cfg: bool, tag_realm_methods: &[(&Cow<'_, str>, V
16031603
}
16041604
println!("impl <'a, TS> {struct_name}<'a, TS>");
16051605
println!("where");
1606-
println!(" TS: KeycloakTokenSupplier,");
1606+
println!(" TS: KeycloakTokenSupplier + Send + Sync,");
16071607
println!("{{");
16081608
for parameter in &optional_parameters {
16091609
if let Some(comment) = &parameter.description {
@@ -1619,7 +1619,7 @@ fn generate_method_builder(add_cfg: bool, tag_realm_methods: &[(&Cow<'_, str>, V
16191619

16201620
println!("impl<TS> Builder<'_, {struct_name}<'_, TS>>");
16211621
println!("where");
1622-
println!(" TS: KeycloakTokenSupplier,");
1622+
println!(" TS: KeycloakTokenSupplier + Send + Sync,");
16231623
println!("{{");
16241624
for parameter in &optional_parameters {
16251625
if let Some(comment) = &parameter.description {
@@ -1709,7 +1709,7 @@ fn generate_method_structs(add_cfg: bool, tag_realm_methods: &[(&Cow<'_, str>, V
17091709
if add_cfg {
17101710
println!("#[cfg(feature = \"tag-{tag_str}\")]",);
17111711
}
1712-
println!("impl<'a, TS: KeycloakTokenSupplier> KeycloakRealmAdminMethod");
1712+
println!("impl<'a, TS: KeycloakTokenSupplier + Send + Sync> KeycloakRealmAdminMethod");
17131713
println!(" for {struct_name}<'a, TS>");
17141714
println!("{{");
17151715
println!(" type Output = {returns};");
@@ -1742,10 +1742,12 @@ fn generate_method_structs(add_cfg: bool, tag_realm_methods: &[(&Cow<'_, str>, V
17421742
}
17431743
println!("impl<'a, TS> IntoFuture for {struct_name}<'a, TS>");
17441744
println!("where");
1745-
println!(" TS: KeycloakTokenSupplier,");
1745+
println!(" TS: KeycloakTokenSupplier + Send + Sync,");
17461746
println!("{{");
17471747
println!(" type Output = Result<{returns}, KeycloakError>;");
1748-
println!(" type IntoFuture = Pin<Box<dyn 'a + Future<Output = Self::Output>>>;");
1748+
println!(
1749+
" type IntoFuture = Pin<Box<dyn 'a + Future<Output = Self::Output> + Send>>;"
1750+
);
17491751

17501752
println!(" fn into_future(self) -> Self::IntoFuture {{");
17511753
println!(" Box::pin(self.opts(Default::default()))");

src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ impl<M: KeycloakRealmAdminMethod> From<M> for Builder<'_, M> {
2323

2424
impl<'m, M: 'm> IntoFuture for Builder<'m, M>
2525
where
26-
M: KeycloakRealmAdminMethod,
26+
M: KeycloakRealmAdminMethod + Send + Sync,
2727
{
2828
type Output = Result<M::Output, KeycloakError>;
29-
type IntoFuture = Pin<Box<dyn 'm + Future<Output = Self::Output>>>;
29+
type IntoFuture = Pin<Box<dyn 'm + Future<Output = Self::Output> + Send>>;
3030

3131
fn into_future(self) -> Self::IntoFuture {
3232
Box::pin(self.method.opts(self.args))

src/resource/client_role_mappings.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ pub struct RealmGroupsWithGroupIdRoleMappingsClientsWithClientIdCompositeGetArgs
305305
pub brief_representation: Option<bool>,
306306
}
307307

308-
impl<'a, TS: KeycloakTokenSupplier> KeycloakRealmAdminMethod
308+
impl<'a, TS: KeycloakTokenSupplier + Send + Sync> KeycloakRealmAdminMethod
309309
for RealmGroupsWithGroupIdRoleMappingsClientsWithClientIdCompositeGet<'a, TS>
310310
{
311311
type Output = TypeVec<RoleRepresentation>;
@@ -331,10 +331,10 @@ impl<'a, TS: KeycloakTokenSupplier> KeycloakRealmAdminMethod
331331
impl<'a, TS> IntoFuture
332332
for RealmGroupsWithGroupIdRoleMappingsClientsWithClientIdCompositeGet<'a, TS>
333333
where
334-
TS: KeycloakTokenSupplier,
334+
TS: KeycloakTokenSupplier + Send + Sync,
335335
{
336336
type Output = Result<TypeVec<RoleRepresentation>, KeycloakError>;
337-
type IntoFuture = Pin<Box<dyn 'a + Future<Output = Self::Output>>>;
337+
type IntoFuture = Pin<Box<dyn 'a + Future<Output = Self::Output> + Send>>;
338338
fn into_future(self) -> Self::IntoFuture {
339339
Box::pin(self.opts(Default::default()))
340340
}
@@ -357,7 +357,7 @@ pub struct RealmUsersWithUserIdRoleMappingsClientsWithClientIdCompositeGetArgs {
357357
pub brief_representation: Option<bool>,
358358
}
359359

360-
impl<'a, TS: KeycloakTokenSupplier> KeycloakRealmAdminMethod
360+
impl<'a, TS: KeycloakTokenSupplier + Send + Sync> KeycloakRealmAdminMethod
361361
for RealmUsersWithUserIdRoleMappingsClientsWithClientIdCompositeGet<'a, TS>
362362
{
363363
type Output = TypeVec<RoleRepresentation>;
@@ -382,10 +382,10 @@ impl<'a, TS: KeycloakTokenSupplier> KeycloakRealmAdminMethod
382382

383383
impl<'a, TS> IntoFuture for RealmUsersWithUserIdRoleMappingsClientsWithClientIdCompositeGet<'a, TS>
384384
where
385-
TS: KeycloakTokenSupplier,
385+
TS: KeycloakTokenSupplier + Send + Sync,
386386
{
387387
type Output = Result<TypeVec<RoleRepresentation>, KeycloakError>;
388-
type IntoFuture = Pin<Box<dyn 'a + Future<Output = Self::Output>>>;
388+
type IntoFuture = Pin<Box<dyn 'a + Future<Output = Self::Output> + Send>>;
389389
fn into_future(self) -> Self::IntoFuture {
390390
Box::pin(self.opts(Default::default()))
391391
}
@@ -400,7 +400,7 @@ mod builder {
400400
// <h4>Client Role Mappings</h4>
401401
impl<'a, TS> RealmGroupsWithGroupIdRoleMappingsClientsWithClientIdCompositeGet<'a, TS>
402402
where
403-
TS: KeycloakTokenSupplier,
403+
TS: KeycloakTokenSupplier + Send + Sync,
404404
{
405405
/// if false, return roles with their attributes
406406
pub fn brief_representation(self, value: impl Into<Option<bool>>) -> Builder<'a, Self> {
@@ -410,7 +410,7 @@ mod builder {
410410

411411
impl<TS> Builder<'_, RealmGroupsWithGroupIdRoleMappingsClientsWithClientIdCompositeGet<'_, TS>>
412412
where
413-
TS: KeycloakTokenSupplier,
413+
TS: KeycloakTokenSupplier + Send + Sync,
414414
{
415415
/// if false, return roles with their attributes
416416
pub fn brief_representation(mut self, value: impl Into<Option<bool>>) -> Self {
@@ -421,7 +421,7 @@ mod builder {
421421

422422
impl<'a, TS> RealmUsersWithUserIdRoleMappingsClientsWithClientIdCompositeGet<'a, TS>
423423
where
424-
TS: KeycloakTokenSupplier,
424+
TS: KeycloakTokenSupplier + Send + Sync,
425425
{
426426
/// if false, return roles with their attributes
427427
pub fn brief_representation(self, value: impl Into<Option<bool>>) -> Builder<'a, Self> {
@@ -431,7 +431,7 @@ mod builder {
431431

432432
impl<TS> Builder<'_, RealmUsersWithUserIdRoleMappingsClientsWithClientIdCompositeGet<'_, TS>>
433433
where
434-
TS: KeycloakTokenSupplier,
434+
TS: KeycloakTokenSupplier + Send + Sync,
435435
{
436436
/// if false, return roles with their attributes
437437
pub fn brief_representation(mut self, value: impl Into<Option<bool>>) -> Self {

0 commit comments

Comments
 (0)