Skip to main content

cloud_sdk/operation/prepared/
service.rs

1//! Provider service identity and endpoint trust binding.
2
3use crate::transport::EndpointPolicy;
4use crate::{ProviderId, ProviderMarker, ServiceId, ServiceMarker};
5
6/// Provider service and immutable endpoint trust policy.
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub struct ProviderService<'endpoint> {
9    provider_id: ProviderId,
10    service_id: ServiceId,
11    endpoint_policy: EndpointPolicy<'endpoint>,
12}
13
14impl<'endpoint> ProviderService<'endpoint> {
15    /// Binds validated provider and service IDs to an endpoint trust policy.
16    #[must_use]
17    pub const fn new(
18        provider_id: ProviderId,
19        service_id: ServiceId,
20        endpoint_policy: EndpointPolicy<'endpoint>,
21    ) -> Self {
22        Self {
23            provider_id,
24            service_id,
25            endpoint_policy,
26        }
27    }
28
29    /// Binds a provider-owned service marker to an endpoint trust policy.
30    #[must_use]
31    pub const fn from_marker<S: ServiceMarker>(endpoint_policy: EndpointPolicy<'endpoint>) -> Self {
32        Self::new(<S::Provider as ProviderMarker>::ID, S::ID, endpoint_policy)
33    }
34
35    /// Returns the canonical provider namespace.
36    #[must_use]
37    pub const fn provider_id(self) -> ProviderId {
38        self.provider_id
39    }
40
41    /// Returns the canonical provider-owned service namespace.
42    #[must_use]
43    pub const fn service_id(self) -> ServiceId {
44        self.service_id
45    }
46
47    /// Returns the immutable endpoint trust policy.
48    #[must_use]
49    pub const fn endpoint_policy(self) -> EndpointPolicy<'endpoint> {
50        self.endpoint_policy
51    }
52}