drive/util/grove_operations/grove_get_path_query/mod.rs
1mod v0;
2
3use crate::drive::Drive;
4use crate::error::drive::DriveError;
5use crate::error::Error;
6use crate::fees::op::LowLevelDriveOperation;
7use dpp::version::drive_versions::DriveVersion;
8use grovedb::query_result_type::{QueryResultElements, QueryResultType};
9use grovedb::{PathQuery, TransactionArg};
10
11impl Drive {
12 /// Retrieves the results of a path query from GroveDB.
13 ///
14 /// # Parameters
15 /// * `path_query`: The path query to execute.
16 /// * `transaction`: The groveDB transaction associated with this operation.
17 /// * `result_type`: The expected type of result of the path query.
18 /// * `drive_operations`: A vector to collect the costs of operations for later computation.
19 /// * `platform_version`: The platform version to select the correct function version to run.
20 ///
21 /// # Returns
22 /// * `Ok((QueryResultElements, u16))` if the operation was successful.
23 /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions.
24 /// * `Err(DriveError::GroveDB)` if the GroveDB operation returned an error.
25 pub fn grove_get_path_query(
26 &self,
27 path_query: &PathQuery,
28 transaction: TransactionArg,
29 result_type: QueryResultType,
30 drive_operations: &mut Vec<LowLevelDriveOperation>,
31 drive_version: &DriveVersion,
32 ) -> Result<(QueryResultElements, u16), Error> {
33 match drive_version.grove_methods.basic.grove_get_path_query {
34 0 => self.grove_get_path_query_v0(
35 path_query,
36 transaction,
37 result_type,
38 drive_operations,
39 drive_version,
40 ),
41 version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
42 method: "grove_get_path_query".to_string(),
43 known_versions: vec![0],
44 received: version,
45 })),
46 }
47 }
48}