Skip to main content

cloud_sdk/pagination/
local_async.rs

1//! Local asynchronous provider-link execution.
2
3use super::{ProviderLinkExecutionError, ValidatedProviderLink};
4use crate::Method;
5use crate::authentication::{
6    AuthenticatedRequest, AuthenticationScopePolicy, LocalAsyncAuthenticatedTransport,
7    drive_local_authenticated,
8};
9use crate::operation::OperationId;
10use crate::transport::{AsyncExecutionError, BoundTransport, RawResponsePolicy, ResponseWriter};
11
12impl ValidatedProviderLink<'_, '_> {
13    /// Validates and executes one authenticated local asynchronous
14    /// continuation request.
15    ///
16    /// Endpoint verification and dispatch use the same transport object. The
17    /// method owns no executor and permits `!Send` futures.
18    pub async fn execute_local_async<'transport, 'request, 'policy, 'writer, T>(
19        &'request self,
20        transport: &'transport T,
21        method: Method,
22        operation: OperationId,
23        authentication: AuthenticationScopePolicy<'policy>,
24        response_policy: RawResponsePolicy<'policy>,
25        response: &'writer mut ResponseWriter<'_>,
26    ) -> Result<(), ProviderLinkExecutionError<T::Error>>
27    where
28        T: BoundTransport + LocalAsyncAuthenticatedTransport,
29        'transport: 'writer,
30        'request: 'writer,
31        'policy: 'writer,
32    {
33        let request = self
34            .request_for(transport, method, operation)
35            .map_err(ProviderLinkExecutionError::Pagination)?;
36        drive_local_authenticated(
37            transport,
38            AuthenticatedRequest::new(request, authentication, response_policy),
39            response,
40        )
41        .await
42        .map_err(|error| match error {
43            AsyncExecutionError::Transport(error) => ProviderLinkExecutionError::Transport(error),
44            AsyncExecutionError::Response(error) => {
45                ProviderLinkExecutionError::ResponseWriter(error)
46            }
47        })
48    }
49}