Skip to main content

unitycatalog_client/codegen/
mod.rs

1// @generated — do not edit by hand.
2pub mod agent_skills;
3pub mod agents;
4pub mod catalogs;
5#[allow(clippy::too_many_arguments, clippy::doc_lazy_continuation)]
6pub mod client;
7pub mod credentials;
8pub mod entity_tag_assignments;
9pub mod external_locations;
10pub mod functions;
11pub mod policies;
12pub mod providers;
13pub mod recipients;
14pub mod schemas;
15pub mod shares;
16pub mod staging_tables;
17pub mod tables;
18pub mod tag_policies;
19pub mod temporary_credentials;
20pub mod volumes;
21#[allow(unused_imports)]
22pub use client::*;
23use futures::Future;
24pub(super) fn stream_paginated<F, Fut, S, T>(
25    state: S,
26    op: F,
27) -> impl futures::Stream<Item = crate::Result<T>>
28where
29    F: Fn(S, Option<String>) -> Fut + Copy,
30    Fut: Future<Output = crate::Result<(T, S, Option<String>)>>,
31{
32    enum PaginationState<T> {
33        Start(T),
34        HasMore(T, String),
35        Done,
36    }
37    futures::stream::unfold(PaginationState::Start(state), move |state| async move {
38        let (s, page_token) = match state {
39            PaginationState::Start(s) => (s, None),
40            PaginationState::HasMore(s, page_token) if !page_token.is_empty() => {
41                (s, Some(page_token))
42            }
43            _ => {
44                return None;
45            }
46        };
47        let (resp, s, continuation) = match op(s, page_token).await {
48            Ok(resp) => resp,
49            Err(e) => return Some((Err(e), PaginationState::Done)),
50        };
51        let next_state = match continuation {
52            Some(token) => PaginationState::HasMore(s, token),
53            None => PaginationState::Done,
54        };
55        Some((Ok(resp), next_state))
56    })
57}