dpp/data_contract/accessors/v0/
mod.rs1use crate::data_contract::config::DataContractConfig;
2use crate::data_contract::document_type::{DocumentType, DocumentTypeRef};
3use crate::data_contract::errors::DataContractError;
4use crate::data_contract::DocumentName;
5
6use platform_value::Identifier;
7use std::collections::BTreeMap;
8
9pub trait DataContractV0Getters {
10 fn id(&self) -> Identifier;
12
13 fn id_ref(&self) -> &Identifier;
14 fn system_version_type(&self) -> u16;
15
16 fn version(&self) -> u32;
18
19 fn owner_id(&self) -> Identifier;
21 fn document_type_cloned_for_name(&self, name: &str) -> Result<DocumentType, DataContractError>;
22 fn document_type_borrowed_for_name(
23 &self,
24 name: &str,
25 ) -> Result<&DocumentType, DataContractError>;
26
27 fn document_type_for_name(&self, name: &str) -> Result<DocumentTypeRef<'_>, DataContractError>;
29
30 fn document_type_optional_for_name(&self, name: &str) -> Option<DocumentTypeRef<'_>>;
31 fn document_type_cloned_optional_for_name(&self, name: &str) -> Option<DocumentType>;
32
33 fn has_document_type_for_name(&self, name: &str) -> bool;
34 fn document_types_with_contested_indexes(&self) -> BTreeMap<&DocumentName, &DocumentType>;
35
36 fn document_types(&self) -> &BTreeMap<DocumentName, DocumentType>;
38
39 fn document_types_mut(&mut self) -> &mut BTreeMap<DocumentName, DocumentType>;
41
42 fn config(&self) -> &DataContractConfig;
44
45 fn config_mut(&mut self) -> &mut DataContractConfig;
47}
48
49pub trait DataContractV0Setters {
50 fn set_id(&mut self, id: Identifier);
52
53 fn set_version(&mut self, version: u32);
55
56 fn increment_version(&mut self);
57
58 fn set_owner_id(&mut self, owner_id: Identifier);
60
61 fn set_config(&mut self, config: DataContractConfig);
63}