Conversation
This makes the API more ergonomic, as `Arc` should really just be an implementation detail, rather than something exposed to the user. This is a followup to the discussion here: #419 (comment)
Arc internally in DatabaseArc internally in Database
There was a problem hiding this comment.
Pull request overview
This PR refactors the Database type to use Arc internally rather than exposing it in the public API, making the framework more ergonomic for users. The change treats reference counting as an implementation detail rather than a user concern.
- Moved
Arcwrapping insideDatabasestruct and addedCloneimplementation - Removed
RequestDbextractor in favor of directDatabaseextraction viaFromRequestHead - Updated all type signatures throughout the codebase from
Arc<Database>toDatabase
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
cot/src/db.rs |
Core refactoring: wraps DatabaseImpl in Arc internally, adds Clone derive, updates all match expressions to dereference the Arc, removes redundant DatabaseBackend impl for Arc<Database> |
cot/src/request/extractors.rs |
Removes RequestDb wrapper struct and implements FromRequestHead directly on Database type |
cot/src/request.rs |
Updates RequestExt trait method signatures to return &Database instead of &Arc<Database> |
cot/src/project.rs |
Updates all type signatures and trait bounds from Arc<Database> to Database throughout bootstrap and context types |
cot/src/session/store/db.rs |
Updates DbStore to store Database instead of Arc<Database>, removes unused Arc import |
cot/src/auth/db.rs |
Updates DatabaseUserBackend to store Database instead of Arc<Database>, removes unused Arc import |
cot/src/test.rs |
Updates TestDatabase and TestRequestBuilder to use Database instead of Arc<Database> throughout |
cot/src/openapi.rs |
Updates ApiOperationPart implementation from RequestDb to Database |
examples/todo-list/src/main.rs |
Updates handler signatures to use db: Database extractor instead of RequestDb(db): RequestDb, adds Database to imports, removes RequestDb import |
examples/forms/src/main.rs |
Updates handler signatures to use db: Database extractor instead of RequestDb(db): RequestDb, adds Database to imports, removes RequestDb import |
examples/admin/src/main.rs |
Updates handler signatures to use db: Database extractor instead of RequestDb(db): RequestDb, adds Database to imports, removes RequestDb import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
| Branch | arc-database |
| Testbed | github-ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| empty_router/empty_router | 📈 view plot 🚷 view threshold | 6,064.30 µs(+0.10%)Baseline: 6,058.53 µs | 6,795.29 µs (89.24%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 1,039.80 µs(+1.50%)Baseline: 1,024.45 µs | 1,131.99 µs (91.86%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 951.80 µs(+0.49%)Baseline: 947.18 µs | 1,042.46 µs (91.30%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 914.14 µs(+0.80%)Baseline: 906.84 µs | 995.54 µs (91.82%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 17,438.00 µs(-1.56%)Baseline: 17,715.17 µs | 20,867.06 µs (83.57%) |
m4tx
added a commit
that referenced
this pull request
Dec 24, 2025
Similarly to #432, this drops the `Arc` from `Arc<Cache>` in public APIs to make the interfaces more ergonomic and easier to use for the users.
ElijahAhianyo
approved these changes
Dec 25, 2025
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This makes the API more ergonomic, as
Arcshould really just be an implementation detail, rather than something exposed to the user.This is a followup to the discussion here:
#419 (comment)