Repository: bottlerocket-os/bottlerocket
File: sources/api/datastore/src/lib.rs (Rust)

Code before:

    /// Remove the given pending transaction from the datastore.  Returns the list of removed
    /// keys.  If the transaction doesn't exist, will return Ok with an empty list.
    fn delete_transaction<S>(&mut self, transaction: S) -> Result<HashSet<Key>>
    where
        S: Into<String> + AsRef<str>;

    /// Returns a list of the names of any pending transactions in the data store.
    fn list_transactions(&self) -> Result<HashSet<String>>;

    /// Set multiple data keys at once in the data store.
    ///
    /// Implementers can replace the default implementation if there's a faster way than setting
    /// each key individually.
    fn set_keys<S>(&mut self, pairs: &HashMap<Key, S>, committed: &Committed) -> Result<()>
    where
        S: AsRef<str>,
    {
        for (key, value) in pairs {
            trace!("Setting data key {}", key.name());
            self.set_key(key, value, committed)?;
        }
        Ok(())
    }
    /// Removes multiple data keys at once in the data store.
    ///
    /// Implementers can replace the default implementation if there's a faster way than
    /// unsetting each key individually.
    fn unset_keys(&mut self, keys: &HashSet<Key>, committed: &Committed) -> Result<()> {
        for key in keys {
            trace!("Unsetting data key {}", key.name());
            self.unset_key(key, committed)?;
        }
        Ok(())
    }

    /// Retrieves all keys starting with the given prefix, returning them in a Key -> value map.
    ///
    /// Can be followed up by a deserialize::from_map call to build a structure.
    fn get_prefix<S: AsRef<str>>(
        &self,
        find_prefix: S,
        committed: &Committed,
    ) -> Result<HashMap<Key, String>> {
        let keys = self.list_populated_keys(&find_prefix, committed)?;
        trace!("Found populated keys: {:?}", keys);
        if keys.is_empty() {
            return Ok(HashMap::new());
        }

        let mut result = HashMap::new();

Review comment (suggestion):
Does it mean this?

```suggestion
            match committed {
                Committed::Live => {
                    info!("Committed data key {}", key.name());
                }
                state => {
                    trace!("Data key {} state changed to {:?}", key.name(), state);
                }
```

Code after:

    /// Remove the given pending transaction from the datastore.  Returns the list of removed
    /// keys.  If the transaction doesn't exist, will return Ok with an empty list.
    fn delete_transaction<S>(&mut self, transaction: S) -> Result<HashSet<Key>>
    where
        S: Into<String> + AsRef<str>;

    /// Returns a list of the names of any pending transactions in the data store.
    fn list_transactions(&self) -> Result<HashSet<String>>;

    /// Set multiple data keys at once in the data store.
    ///
    /// Implementers can replace the default implementation if there's a faster way than setting
    /// each key individually.
    fn set_keys<S>(&mut self, pairs: &HashMap<Key, S>, committed: &Committed) -> Result<()>
    where
        S: AsRef<str>,
    {
        for (key, value) in pairs {
            match committed {
                Committed::Live => {
                    info!("Committed data key {}", key.name());
                }
                state => {
                    trace!("Data key {} state changed to {:?}", key.name(), state);
                }
            };
            self.set_key(key, value, committed)?;
        }
        Ok(())
    }
    /// Removes multiple data keys at once in the data store.
    ///
    /// Implementers can replace the default implementation if there's a faster way than
    /// unsetting each key individually.
    fn unset_keys(&mut self, keys: &HashSet<Key>, committed: &Committed) -> Result<()> {
        for key in keys {
            trace!("Unsetting data key {}", key.name());
            self.unset_key(key, committed)?;
        }
        Ok(())
    }

    /// Retrieves all keys starting with the given prefix, returning them in a Key -> value map.
    ///
    /// Can be followed up by a deserialize::from_map call to build a structure.
    fn get_prefix<S: AsRef<str>>(
        &self,
        find_prefix: S,
        committed: &Committed,
    ) -> Result<HashMap<Key, String>> {