dpp/document/document_methods/
mod.rs

1use crate::data_contract::document_type::DocumentTypeRef;
2use crate::data_contract::DataContract;
3use crate::version::PlatformVersion;
4use crate::ProtocolError;
5
6mod get_raw_for_contract;
7mod get_raw_for_document_type;
8mod hash;
9mod is_equal_ignoring_timestamps;
10
11pub(in crate::document) use get_raw_for_contract::*;
12pub(in crate::document) use get_raw_for_document_type::*;
13pub(in crate::document) use hash::*;
14pub(in crate::document) use is_equal_ignoring_timestamps::*;
15
16pub trait DocumentMethodsV0 {
17    /// Return a value given the path to its key and the document type for a contract.
18    fn get_raw_for_contract(
19        &self,
20        key: &str,
21        document_type_name: &str,
22        contract: &DataContract,
23        owner_id: Option<[u8; 32]>,
24        platform_version: &PlatformVersion,
25    ) -> Result<Option<Vec<u8>>, ProtocolError>;
26
27    /// Return a value given the path to its key for a document type.
28    fn get_raw_for_document_type(
29        &self,
30        key_path: &str,
31        document_type: DocumentTypeRef,
32        owner_id: Option<[u8; 32]>,
33        platform_version: &PlatformVersion,
34    ) -> Result<Option<Vec<u8>>, ProtocolError>;
35
36    fn hash(
37        &self,
38        contract: &DataContract,
39        document_type: DocumentTypeRef,
40        platform_version: &PlatformVersion,
41    ) -> Result<Vec<u8>, ProtocolError>;
42
43    fn increment_revision(&mut self) -> Result<(), ProtocolError>;
44
45    /// Checks to see if a document is equal without time based fields.
46    /// Since these fields are set on the network this function can be useful to make sure that
47    /// fields that were supplied have not changed, while ignoring those that are set network side.
48    /// Time based fields that are ignored are
49    ///     created_at/updated_at
50    ///     created_at_block_height/updated_at_block_height
51    ///     created_at_core_block_height/updated_at_core_block_height
52    fn is_equal_ignoring_time_based_fields(
53        &self,
54        rhs: &Self,
55        also_ignore_fields: Option<Vec<&str>>,
56        platform_version: &PlatformVersion,
57    ) -> Result<bool, ProtocolError>;
58}