Skip to content

Conversation

curquiza
Copy link
Member

@curquiza curquiza commented Sep 18, 2025

Summary by CodeRabbit

  • Refactor

    • Public query builder APIs now use explicit lifetimes, improving type clarity when borrowing clients or indexes.
    • No runtime behavior changes; only type signatures are adjusted.
  • Chores

    • Harmonized return types across search, document, and index-related builders to consistently reflect lifetimes.
  • Notes

    • This may require minor source updates for projects relying on inferred lifetimes in return types.

@curquiza curquiza added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Sep 18, 2025
Copy link
Contributor

coderabbitai bot commented Sep 18, 2025

Walkthrough

Public API signatures were updated across client, documents, and indexes modules to add explicit lifetimes to query-builder return types. Implementations and control flow remain unchanged. The changes align returned builders with the lifetime of borrowed inputs (self or client/index references).

Changes

Cohort / File(s) Summary
Client query builder lifetimes
src/client.rs
Changed Client::multi_search return type from MultiSearchQuery<Http> to MultiSearchQuery<'_, '_, Http>; method body unchanged.
Document query builder lifetimes
src/documents.rs
Updated constructors to return lifetime-parameterized types: DocumentQuery<'_, Http>, DocumentsQuery<'_, Http>, DocumentDeletionQuery<'_, Http>; bodies unchanged.
Index and queries lifetimes
src/indexes.rs
Updated return types to carry lifetimes: Index::search -> SearchQuery<'_, Http>, IndexUpdater::new -> IndexUpdater<'_, Http>, IndexesQuery::new -> IndexesQuery<'_, Http>; no logic changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A rabbit taps keys with delight,
Lifetimes now snug, safely tight.
Queries that borrow, clear as dawn,
Builders hop where refs are drawn.
No flow disturbed, just tidy bounds—
Rusty meadows, lifetimes sound.
🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Fix clippy" accurately and concisely describes the PR's intent to address Clippy lints; the provided summary shows only lifetime/signature adjustments across client, documents, and indexes that align with lint-driven fixes, so the title is related to the main change. It is brief and focused, though somewhat terse.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch clippy

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c029adb and 5aa3bb0.

📒 Files selected for processing (3)
  • src/client.rs (1 hunks)
  • src/documents.rs (3 hunks)
  • src/indexes.rs (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-12T13:28:23.700Z
Learnt from: LukasKalbertodt
PR: meilisearch/meilisearch-rust#625
File: src/search.rs:368-370
Timestamp: 2025-06-12T13:28:23.700Z
Learning: In the Meilisearch Rust client, `SearchQuery` serializes its per-query federation settings under the key `federationOptions`; only the top-level multi-search parameter is named `federation`.

Applied to files:

  • src/client.rs
🧬 Code graph analysis (2)
src/indexes.rs (3)
src/search.rs (8)
  • SearchQuery (1834-1837)
  • SearchQuery (1849-1852)
  • SearchQuery (1864-1867)
  • SearchQuery (1879-1881)
  • new (39-41)
  • new (414-446)
  • new (733-738)
  • new (985-996)
src/documents.rs (3)
  • new (89-94)
  • new (203-211)
  • new (335-340)
src/similar.rs (1)
  • new (133-147)
src/documents.rs (2)
src/client.rs (2)
  • new (50-62)
  • index (420-422)
src/indexes.rs (10)
  • new (81-89)
  • new (1780-1786)
  • new (1979-1985)
  • index (2156-2156)
  • index (2173-2174)
  • index (2211-2211)
  • index (2237-2237)
  • index (2265-2265)
  • index (2291-2291)
  • index (2318-2318)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: integration-tests
🔇 Additional comments (8)
src/client.rs (2)

205-207: Lifetimed return type for multi_search is correct.

Ties the builder to &self; aligns with other builders.


118-129: Fix turbofish generics: let the compiler infer query/body types

Replace explicit &... turbofish in request::<...> calls with underscores so the lifetimed builders can compile.

Locations: src/client.rs — primary snippet at ~lines 118–129; also apply at 131–144, 349–358, 993–1004, 1028–1041, 1069–1076.

@@ async fn execute_multi_search_query
-            .request::<(), &MultiSearchQuery<Http>, MultiSearchResponse<T>>(
+            .request::<(), _, MultiSearchResponse<T>>(
@@ async fn execute_federated_multi_search_query
-            .request::<(), &FederatedMultiSearchQuery<Http>, FederatedMultiSearchResponse<T>>(
+            .request::<(), _, FederatedMultiSearchResponse<T>>(
@@ pub async fn list_all_indexes_raw_with
-            .request::<&IndexesQuery<Http>, (), Value>(
+            .request::<_, (), Value>(
@@ pub async fn get_tasks_with
-            .request::<&TasksSearchQuery<Http>, (), TasksResults>(
+            .request::<_, (), TasksResults>(
@@ pub async fn cancel_tasks_with
-            .request::<&TasksCancelQuery<Http>, (), TaskInfo>(
+            .request::<_, (), TaskInfo>(
@@ pub async fn delete_tasks_with
-            .request::<&TasksDeleteQuery<Http>, (), TaskInfo>(
+            .request::<_, (), TaskInfo>(

Sandbox search returned no matches; run locally to verify no remaining instances:

rg -nP '\brequest::?<[^>]*<\s*&(?:MultiSearchQuery|FederatedMultiSearchQuery|IndexesQuery|Tasks(?:Search|Cancel|Delete)Query)<Http>' -C2
src/documents.rs (3)

89-94: DocumentQuery::new() lifetime is fine.

Return type correctly reflects borrowing from &Index.


203-211: DocumentsQuery::new() lifetime is fine.

Consistent with builder holding &'a Index.


335-340: DocumentDeletionQuery::new() lifetime is fine.

Matches the pattern used elsewhere.

src/indexes.rs (3)

279-281: search() lifetime change is correct.

Builder borrows &self; explicit lifetime makes that clear.


1780-1786: IndexUpdater::new() lifetime is fine.

Return type now correctly ties to &Client.


1979-1985: IndexesQuery::new() lifetime is fine.

Consistent with other builder constructors.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.69%. Comparing base (c029adb) to head (5aa3bb0).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/documents.rs 66.66% 1 Missing ⚠️
src/indexes.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #707      +/-   ##
==========================================
+ Coverage   85.67%   85.69%   +0.02%     
==========================================
  Files          19       19              
  Lines        5883     5853      -30     
==========================================
- Hits         5040     5016      -24     
+ Misses        843      837       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

LGTM

bors merge

Copy link
Contributor

meili-bors bot commented Sep 18, 2025

Build succeeded:

@meili-bors meili-bors bot merged commit 72683bf into main Sep 18, 2025
10 of 11 checks passed
@meili-bors meili-bors bot deleted the clippy branch September 18, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Anything related to maintenance (CI, tests, refactoring...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants