drive/util/grove_operations/grove_clear/
mod.rs

1mod v0;
2
3use crate::drive::Drive;
4use crate::error::drive::DriveError;
5use crate::error::Error;
6
7use dpp::version::drive_versions::DriveVersion;
8
9use grovedb::TransactionArg;
10use grovedb_path::SubtreePath;
11
12impl Drive {
13    /// Handles the deletion of an element in GroveDB at the specified path and key.
14    /// The operation cost is added to `drive_operations` for later processing.
15    ///
16    /// # Parameters
17    /// * `path`: The groveDB hierarchical authenticated structure path where the subtree is to be cleared.
18    /// * `transaction`: The groveDB transaction associated with this operation.
19    /// * `drive_operations`: A vector to collect the costs of operations for later computation.
20    /// * `platform_version`: The platform version to select the correct function version to run.
21    ///
22    /// # Returns
23    /// * `Ok(())` if the operation was successful.
24    /// * `Err(DriveError::UnknownVersionMismatch)` if the platform version does not match known versions.
25    pub fn grove_clear<B: AsRef<[u8]>>(
26        &self,
27        path: SubtreePath<'_, B>,
28        transaction: TransactionArg,
29        drive_version: &DriveVersion,
30    ) -> Result<(), Error> {
31        match drive_version.grove_methods.basic.grove_clear {
32            0 => self.grove_clear_v0(path, transaction, drive_version),
33            version => Err(Error::Drive(DriveError::UnknownVersionMismatch {
34                method: "grove_clear".to_string(),
35                known_versions: vec![0],
36                received: version,
37            })),
38        }
39    }
40}