Skip to main content

coil_core/manifest/
data.rs

1use super::*;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum DataRepositoryPrincipalBinding {
5    Omit,
6    InvocationPrincipal,
7}
8
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct DataRepositoryQueryProfile {
11    pub page: PageRequest,
12    pub publication_visibility: PublicationVisibility,
13    pub default_cache_scope: QueryCacheScope,
14    pub localized_cache_scope: QueryCacheScope,
15    pub principal_binding: DataRepositoryPrincipalBinding,
16}
17
18impl DataRepositoryQueryProfile {
19    pub fn new(
20        page: PageRequest,
21        publication_visibility: PublicationVisibility,
22        cache_scope: QueryCacheScope,
23    ) -> Self {
24        Self {
25            page,
26            publication_visibility,
27            default_cache_scope: cache_scope,
28            localized_cache_scope: cache_scope,
29            principal_binding: DataRepositoryPrincipalBinding::Omit,
30        }
31    }
32
33    pub fn with_localized_cache_scope(mut self, cache_scope: QueryCacheScope) -> Self {
34        self.localized_cache_scope = cache_scope;
35        self
36    }
37
38    pub fn bind_invocation_principal(mut self) -> Self {
39        self.principal_binding = DataRepositoryPrincipalBinding::InvocationPrincipal;
40        self
41    }
42}
43
44#[derive(Debug, Clone, PartialEq, Eq)]
45pub struct DataRepositoryContribution {
46    pub id: String,
47    pub repository: RepositorySpec,
48    pub query_profile: DataRepositoryQueryProfile,
49}
50
51impl DataRepositoryContribution {
52    pub fn new(repository: RepositorySpec, query_profile: DataRepositoryQueryProfile) -> Self {
53        Self {
54            id: repository.id.clone(),
55            repository,
56            query_profile,
57        }
58    }
59}