feat(primitives): create torrust-net-primitives and move ServiceBinding (#1797)#1799
Merged
josecelano merged 6 commits intoMay 20, 2026
Conversation
…ng (torrust#1797) Moves ServiceBinding out of torrust-tracker-primitives into a new dedicated torrust-net-primitives crate. torrust-server-lib now depends on torrust-net-primitives instead of torrust-tracker-primitives, breaking an unnecessary coupling between a generic server utility and tracker-specific types. Changes: - Create packages/net-primitives/ with Cargo.toml, src/lib.rs, and README.md - Add packages/net-primitives to workspace [members] in root Cargo.toml - Move service_binding module to packages/net-primitives/src/ - Replace service_binding module in packages/primitives/src/ with a #[deprecated] re-export from torrust_net_primitives for backwards compatibility with external crates.io consumers - Add torrust-net-primitives dep to packages/primitives/Cargo.toml - Update packages/server-lib/Cargo.toml: replace torrust-tracker-primitives dep with torrust-net-primitives (ServiceBinding was its only use) - Add torrust-net-primitives dep to all other packages importing ServiceBinding: axum-health-check-api-server, axum-http-tracker-server, axum-rest-tracker-api-server, http-tracker-core, tracker-client, udp-tracker-core, udp-tracker-server - Update all workspace import paths from torrust_tracker_primitives::service_binding to torrust_net_primitives::service_binding across ~45 files All acceptance criteria verified: - cargo build --workspace: clean - linter all: exit code 0 - pre-commit hook: pass Part of torrust#1669 (SI-05)
There was a problem hiding this comment.
Pull request overview
Extracts ServiceBinding (and Protocol) from torrust-tracker-primitives into a new dedicated torrust-net-primitives crate, breaking the unnecessary coupling between torrust-server-lib and tracker-specific primitives.
Changes:
- New
packages/net-primitivescrate (publish = true) hostingservice_bindingmodule (moved frompackages/primitives). packages/primitiveskeeps a#[deprecated]re-export ofservice_bindingfor crates.io backwards compatibility.- All workspace consumers (server-lib, axum servers, http/udp tracker core/server, tracker-client) updated to import from
torrust_net_primitives::service_binding;server-libno longer depends ontorrust-tracker-primitives.
Reviewed changes
Copilot reviewed 53 out of 54 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/net-primitives/{Cargo.toml,README.md,src/lib.rs,src/service_binding.rs} | New crate scaffolding and moved module |
| packages/primitives/{Cargo.toml,src/lib.rs} | Drop module, add #[deprecated] re-export, depend on net-primitives |
| packages/server-lib/{Cargo.toml,src/registar.rs,src/signals.rs} | Swap dep and imports |
| packages/{axum-health-check-api-server,axum-http-tracker-server,axum-rest-tracker-api-server,http-tracker-core,udp-tracker-core,udp-tracker-server,tracker-client}/** | Add dep and update imports |
| Cargo.toml, Cargo.lock | Workspace members and lockfile updates |
| docs/issues/open/1797-*, docs/issues/open/1669-overhaul-packages/{EPIC.md,workspace-coupling-report.md} | Spec promoted to open, EPIC updated, coupling report regenerated |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1799 +/- ##
===========================================
+ Coverage 77.64% 77.69% +0.04%
===========================================
Files 379 379
Lines 28602 28607 +5
Branches 28602 28607 +5
===========================================
+ Hits 22209 22226 +17
+ Misses 6080 6072 -8
+ Partials 313 309 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Without this feature, derive_more::Display was unavailable when compiling bittorrent-tracker-client in isolation. It previously worked only because of accidental transitive feature unification via primitives -> configuration, which was removed in torrust#1795. Fixes E2E CI failure on PR torrust#1799.
Member
Author
|
ACK 88de3d5 |
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.
Moves
ServiceBindingout oftorrust-tracker-primitivesinto a new dedicatedtorrust-net-primitivescrate.torrust-server-libnow depends ontorrust-net-primitivesinstead oftorrust-tracker-primitives, breaking anunnecessary coupling between a generic server utility and tracker-specific types.
Motivation
The coupling analysis (F-04 in EPIC #1669) found that
torrust-server-libdepended on
torrust-tracker-primitivessolely to importServiceBinding— astruct representing a network address binding.
torrust-server-libhas notracker-specific concerns; pulling in the entire
torrust-tracker-*primitivescrate for one generic networking type is wasteful and semantically misleading.
ServiceBindingis a generic concept reusable across the Torrust organisation,not just the tracker. A dedicated
torrust-net-primitivescrate makes the typeavailable to any Torrust project without a
torrust-tracker-*dependency.Changes
New crate
packages/net-primitives/— newtorrust-net-primitivescrate (publish = true)src/service_binding.rs—ServiceBindingandProtocol(moved frompackages/primitives/)src/lib.rs— exportspub mod service_bindingREADME.mdUpdated workspace root
Cargo.toml— addedpackages/net-primitivesto[workspace] membersCargo.lock— updatedUpdated packages (Cargo.toml + import paths)
packages/primitives/— removedservice_bindingmodule definition; added#[deprecated]re-export fromtorrust_net_primitivesfor external crates.ioconsumer backwards compatibility (same pattern as
DurationSinceUnixEpochandAnnouncePolicy)packages/server-lib/— replacedtorrust-tracker-primitivesdep withtorrust-net-primitives(ServiceBinding was its only use)packages/axum-health-check-api-server/,packages/axum-http-tracker-server/,packages/axum-rest-tracker-api-server/,packages/http-tracker-core/,packages/tracker-client/,packages/udp-tracker-core/,packages/udp-tracker-server/— addedtorrust-net-primitivesdep; updatedall import paths from
torrust_tracker_primitives::service_bindingtotorrust_net_primitives::service_bindingacross ~45 source filesDocs
docs/issues/open/1797-1669-05-create-torrust-net-primitives-and-move-service-binding.md— specdocs/issues/open/1669-overhaul-packages/EPIC.md— SI-05 updated to reference Createtorrust-net-primitivesand moveServiceBindingfromtorrust-tracker-primitives#1797docs/issues/open/1669-overhaul-packages/workspace-coupling-report.md— regeneratedValidation
cargo build --workspacecargo test --workspacelinter allcargo machetecargo +nightly fmt --checkcargo +nightly check --workspace --all-targetscargo +nightly doc --no-deps --workspacegrep "torrust_tracker_primitives::.*ServiceBinding" --include="*.rs" -r .grep "torrust-tracker-primitives" packages/server-lib/Cargo.tomlCloses #1797
Part of #1669 (SI-05)