drive/util/grove_operations/grove_get_raw_item/
mod.rs

1mod v0;
2
3use crate::drive::Drive;
4use crate::error::drive::DriveError;
5use crate::error::Error;
6use crate::fees::op::LowLevelDriveOperation;
7use crate::util::grove_operations::DirectQueryType;
8
9use dpp::version::drive_versions::DriveVersion;
10
11use grovedb::TransactionArg;
12use grovedb_path::SubtreePath;
13
14impl Drive {
15    /// Handles the retrieval of a raw element from GroveDB at the specified path and key.
16    /// The operation cost is added to `drive_operations` for later processing.
17    ///
18    /// # Parameters
19    /// * `path`: The groveDB hierarchical authenticated structure path from where the element is to be retrieved.
20    /// * `key`: The key of the element to be retrieved from the subtree.
21    /// * `direct_query_type`: The type of query to perform, whether stateless or stateful.
22    /// * `transaction`: The groveDB transaction associated with this operation.
23    /// * `drive_operations`: A vector to collect the costs of operations for later computation.
24    /// * `platform_version`: The platform version to select the correct function version to run.
25    ///
26    /// # Returns
27    /// * `Ok(Some(Element))` if the operation was successful and the element was found.
28    /// * `Ok(None)` if the operation was successful but the element was not found.
29    /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions.
30    pub fn grove_get_raw_item<B: AsRef<[u8]>>(
31        &self,
32        path: SubtreePath<'_, B>,
33        key: &[u8],
34        direct_query_type: DirectQueryType,
35        transaction: TransactionArg,
36        drive_operations: &mut Vec<LowLevelDriveOperation>,
37        drive_version: &DriveVersion,
38    ) -> Result<Vec<u8>, Error> {
39        match drive_version.grove_methods.basic.grove_get_raw_item {
40            0 => self.grove_get_raw_item_v0(
41                path,
42                key,
43                direct_query_type,
44                transaction,
45                drive_operations,
46                drive_version,
47            ),
48            version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
49                method: "grove_get_raw_item".to_string(),
50                known_versions: vec![0],
51                received: version,
52            })),
53        }
54    }
55}