daml_grpc/data/
features.rs1use std::time::Duration;
2
3use crate::grpc_protobuf::com::daml::ledger::api::v2::{
4 ExperimentalCommandInspectionService, ExperimentalFeatures, ExperimentalStaticTime, FeaturesDescriptor,
5 OffsetCheckpointFeature, PackageFeature, PartyManagementFeature, UserManagementFeature,
6};
7
8#[derive(Debug, Eq, PartialEq, Clone, Default)]
13pub struct DamlLedgerApiVersion {
14 pub version: String,
15 pub features: Option<DamlFeaturesDescriptor>,
16}
17
18#[derive(Debug, Eq, PartialEq, Clone, Default)]
26pub struct DamlFeaturesDescriptor {
27 pub experimental: Option<DamlExperimentalFeatures>,
28 pub user_management: Option<DamlUserManagementFeature>,
29 pub party_management: Option<DamlPartyManagementFeature>,
30 pub offset_checkpoint: Option<DamlOffsetCheckpointFeature>,
31 pub package: Option<DamlPackageFeature>,
32}
33
34impl From<FeaturesDescriptor> for DamlFeaturesDescriptor {
35 fn from(f: FeaturesDescriptor) -> Self {
36 Self {
37 experimental: f.experimental.map(DamlExperimentalFeatures::from),
38 user_management: f.user_management.map(DamlUserManagementFeature::from),
39 party_management: f.party_management.map(DamlPartyManagementFeature::from),
40 offset_checkpoint: f.offset_checkpoint.map(DamlOffsetCheckpointFeature::from),
41 package: f.package_feature.map(DamlPackageFeature::from),
42 }
43 }
44}
45
46#[derive(Debug, Eq, PartialEq, Clone, Default)]
47pub struct DamlExperimentalFeatures {
48 pub static_time: Option<DamlExperimentalStaticTime>,
49 pub command_inspection_service: Option<DamlExperimentalCommandInspectionService>,
50}
51
52impl From<ExperimentalFeatures> for DamlExperimentalFeatures {
53 fn from(f: ExperimentalFeatures) -> Self {
54 Self {
55 static_time: f.static_time.map(DamlExperimentalStaticTime::from),
56 command_inspection_service: f
57 .command_inspection_service
58 .map(DamlExperimentalCommandInspectionService::from),
59 }
60 }
61}
62
63#[derive(Debug, Eq, PartialEq, Clone, Default)]
64pub struct DamlExperimentalStaticTime {
65 pub supported: bool,
66}
67
68impl From<ExperimentalStaticTime> for DamlExperimentalStaticTime {
69 fn from(f: ExperimentalStaticTime) -> Self {
70 Self {
71 supported: f.supported,
72 }
73 }
74}
75
76#[derive(Debug, Eq, PartialEq, Clone, Default)]
77pub struct DamlExperimentalCommandInspectionService {
78 pub supported: bool,
79}
80
81impl From<ExperimentalCommandInspectionService> for DamlExperimentalCommandInspectionService {
82 fn from(f: ExperimentalCommandInspectionService) -> Self {
83 Self {
84 supported: f.supported,
85 }
86 }
87}
88
89#[derive(Debug, Eq, PartialEq, Clone, Default)]
90pub struct DamlUserManagementFeature {
91 pub supported: bool,
92 pub max_rights_per_user: i32,
94 pub max_users_page_size: i32,
96}
97
98impl From<UserManagementFeature> for DamlUserManagementFeature {
99 fn from(f: UserManagementFeature) -> Self {
100 Self {
101 supported: f.supported,
102 max_rights_per_user: f.max_rights_per_user,
103 max_users_page_size: f.max_users_page_size,
104 }
105 }
106}
107
108#[derive(Debug, Eq, PartialEq, Clone, Default)]
109pub struct DamlPartyManagementFeature {
110 pub max_parties_page_size: i32,
111}
112
113impl From<PartyManagementFeature> for DamlPartyManagementFeature {
114 fn from(f: PartyManagementFeature) -> Self {
115 Self {
116 max_parties_page_size: f.max_parties_page_size,
117 }
118 }
119}
120
121#[derive(Debug, Eq, PartialEq, Clone, Default)]
122pub struct DamlPackageFeature {
123 pub max_vetted_packages_page_size: i32,
124}
125
126impl From<PackageFeature> for DamlPackageFeature {
127 fn from(f: PackageFeature) -> Self {
128 Self {
129 max_vetted_packages_page_size: f.max_vetted_packages_page_size,
130 }
131 }
132}
133
134#[derive(Debug, Eq, PartialEq, Clone, Default)]
135pub struct DamlOffsetCheckpointFeature {
136 pub max_offset_checkpoint_emission_delay: Duration,
137}
138
139impl From<OffsetCheckpointFeature> for DamlOffsetCheckpointFeature {
140 fn from(f: OffsetCheckpointFeature) -> Self {
141 Self {
142 max_offset_checkpoint_emission_delay: f
143 .max_offset_checkpoint_emission_delay
144 .and_then(|d| Duration::try_from(d).ok())
145 .unwrap_or_default(),
146 }
147 }
148}