Skip to content

RMST-236: iterates the list of signatures in CollectionMetadata#7270

Merged
leplatrem merged 3 commits intomainfrom
RMST-236
Mar 20, 2026
Merged

RMST-236: iterates the list of signatures in CollectionMetadata#7270
leplatrem merged 3 commits intomainfrom
RMST-236

Conversation

@leplatrem
Copy link
Contributor

@leplatrem leplatrem commented Mar 16, 2026

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@leplatrem leplatrem force-pushed the RMST-236 branch 5 times, most recently from c7d3140 to d47a3a3 Compare March 18, 2026 12:13
Copy link
Contributor

@alexcottner alexcottner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks reasonable to me

@leplatrem
Copy link
Contributor Author

Is it more idiomatic to do this as it was?

--- a/components/remote_settings/src/storage.rs
+++ b/components/remote_settings/src/storage.rs
@@ -140,7 +140,7 @@ impl Storage {
         let mut stmt_metadata = tx.prepare(
             "SELECT bucket, signatures FROM collection_metadata WHERE collection_url = ?",
         )?;
-        let result = stmt_metadata
+        if let Some(metadata) = stmt_metadata
             .query_row(params![collection_url], |row| {
                 let bucket: String = row.get(0)?;
                 let signatures_json: String = row.get(1)?;
@@ -154,8 +154,12 @@ impl Storage {
                 })?;
                 Ok(CollectionMetadata { bucket, signatures })
             })
-            .optional()?;
-        Ok(result)
+            .optional()?
+        {
+            Ok(Some(metadata))
+        } else {
+            Ok(None)
+        }
     }

@alexcottner
Copy link
Contributor

Is it more idiomatic to do this as it was?

I think I prefer the way you have it now slightly. But I'm still somewhat new to rust.

@bendk
Copy link
Contributor

bendk commented Mar 20, 2026

Is it more idiomatic to do this as it was?

I think I prefer the way you have it now slightly. But I'm still somewhat new to rust.

I think the way you have it is fine. But maybe you could just do something like this:

stmt_metadata
  .query_row(params![collection_url], |row| {
    // ...
   })
   .optional()

Copy link
Contributor

@bendk bendk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks right to me and the tests are great. I left a few suggestions, but none of them are required. Whatever you think is best is good with me.

@bendk
Copy link
Contributor

bendk commented Mar 20, 2026

BTW, I don't think it helps here but there's also the .transpose() method which swaps between Result<Option<T>> and Option<Result<T>>. I find that useful in a lot of situations where you're dealing with both. When the types get too complicated to track in my mind, I usually write the types out explicitly and see what works:

let foo: Option<Foo> = some_computation()
   .map(|result| 
     // some more complicated stuff
   )?;
   // and if that doesn't work, I change the last line to ).transpose()?

@leplatrem leplatrem added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit ce73c63 Mar 20, 2026
13 checks passed
@leplatrem leplatrem deleted the RMST-236 branch March 20, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants