From 7eb1aa25181dd52d6d678bf681e18339a26b0a49 Mon Sep 17 00:00:00 2001 From: Vlad Zagvozdkin Date: Fri, 17 Jan 2025 18:56:44 +0500 Subject: [PATCH] feat: add Sync to pagination types --- src/v2/management/mod.rs | 2 +- src/v2/pagination.rs | 16 ++++++++-------- src/v2/users/mod.rs | 9 ++++++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/v2/management/mod.rs b/src/v2/management/mod.rs index 5cb4300..44c5537 100644 --- a/src/v2/management/mod.rs +++ b/src/v2/management/mod.rs @@ -59,7 +59,7 @@ impl Zitadel { pub fn search_actions( &self, body: ListActionsRequest, - ) -> Result + Send> { + ) -> Result + Send + Sync> { Ok(PaginationHandler::<_, V1Action>::new( self.clone(), body, diff --git a/src/v2/pagination.rs b/src/v2/pagination.rs index a1d7798..f840d93 100644 --- a/src/v2/pagination.rs +++ b/src/v2/pagination.rs @@ -30,15 +30,15 @@ pub(crate) trait PaginationRequest { fn page_size(&self) -> usize; } -type DataFuture = dyn Future>> + Send; +type DataFuture = dyn Future>> + Send + Sync; pub(crate) struct PaginationHandler where - Q: Serialize + Send, + Q: Serialize + Send + Sync, T: DeserializeOwned + 'static, { zitadel: Zitadel, - query: Box + Send>, + query: Box + Send + Sync>, endpoint: Url, page: usize, buffer: Vec, @@ -48,12 +48,12 @@ where impl PaginationHandler where - Q: Serialize + Send + 'static, + Q: Serialize + Send + Sync + 'static, T: DeserializeOwned + 'static, { pub(crate) fn new( zitadel: Zitadel, - query: impl PaginationRequest + Send + 'static, + query: impl PaginationRequest + Send + Sync + 'static, endpoint: Url, ) -> Self { let page = 0; @@ -72,7 +72,7 @@ where async fn get_more_data( zitadel: Zitadel, - query: impl Serialize + Send, + query: impl Serialize + Send + Sync, endpoint: Url, ) -> Result> { let request = zitadel @@ -88,14 +88,14 @@ async fn get_more_data( impl Unpin for PaginationHandler where - Q: Serialize + Send + 'static, + Q: Serialize + Send + Sync + 'static, T: DeserializeOwned + 'static, { } impl Stream for PaginationHandler where - Q: Serialize + Send + 'static, + Q: Serialize + Send + Sync + 'static, T: DeserializeOwned + 'static, { type Item = T; diff --git a/src/v2/users/mod.rs b/src/v2/users/mod.rs index 7ed8ea7..05eedc1 100644 --- a/src/v2/users/mod.rs +++ b/src/v2/users/mod.rs @@ -146,7 +146,7 @@ impl Zitadel { &self, user_id: &str, body: UserServiceListIdpLinksBody, - ) -> Result + Send> { + ) -> Result + Send + Sync> { Ok(PaginationHandler::<_, IdpLink>::new( self.clone(), body, @@ -172,7 +172,10 @@ impl Zitadel { /// Search Users /// Search for users. By default, we will return users of your organization. /// Make sure to include a limit and sorting for pagination. - pub fn list_users(&self, body: ListUsersRequest) -> Result + Send> { + pub fn list_users( + &self, + body: ListUsersRequest, + ) -> Result + Send + Sync> { Ok(PaginationHandler::<_, User>::new(self.clone(), body, self.make_url("/v2/users")?)) } /// Lock user @@ -668,7 +671,7 @@ impl Zitadel { &self, user_id: &str, body: ListUserMetadataRequest, - ) -> Result + Send> { + ) -> Result + Send + Sync> { Ok(PaginationHandler::<_, UserMetadataResponse>::new( self.clone(), body,