Skip to content

refactor: make hl7v2-network a compatibility shim#425

Merged
EffortlessSteven merged 1 commit intomainfrom
refactor/hl7v2-network-compat-shim
May 7, 2026
Merged

refactor: make hl7v2-network a compatibility shim#425
EffortlessSteven merged 1 commit intomainfrom
refactor/hl7v2-network-compat-shim

Conversation

@EffortlessSteven
Copy link
Copy Markdown
Member

Summary

  • turn hl7v2-network into a deprecated compatibility crate over hl7v2::transport::network
  • remove the old network implementation files from the compatibility crate
  • keep the existing hl7v2-network integration tests running against the shimmed crate name
  • preserve the legacy tls feature as an empty compatibility feature

Validation

  • cargo +1.93.0 fmt --all -- --check
  • cargo +1.93.0 check -p hl7v2-network --all-features --all-targets
  • cargo +1.93.0 test -p hl7v2-network --all-features
  • cargo +1.93.0 test -p hl7v2 --features network
  • cargo +1.93.0 check -p hl7v2-server --all-features
  • cargo +1.93.0 check --examples
  • $env:PYO3_USE_ABI3_FORWARD_COMPATIBILITY='1'; cargo +1.93.0 run -p xtask -- gate --check --changed
  • $env:PYO3_USE_ABI3_FORWARD_COMPATIBILITY='1'; cargo +1.93.0 run -p xtask -- publish-dry-run --from hl7v2 --workspace-patches

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

Summary by CodeRabbit

  • Deprecation

    • hl7v2-network is now deprecated as a compatibility crate. All MLLP TCP functionality remains available; new implementations should use hl7v2::transport::network directly.
  • Chores

    • Consolidated internal dependencies and reorganized module structure for improved maintainability.

Walkthrough

The hl7v2-network crate is refactored from a standalone HL7 MLLP networking implementation into a deprecated compatibility wrapper. Dependencies consolidate from separate hl7v2-model, hl7v2-parser, hl7v2-writer crates into a single hl7v2 dependency with the network feature. The crate's public API remains unchanged via wildcard re-export from hl7v2::transport::network. Test utilities and comprehensive test suites are updated to use unified error and message types.

Changes

hl7v2-network migration to unified transport module

Layer / File(s) Summary
Dependency consolidation
crates/hl7v2-network/Cargo.toml
Multiple HL7v2 component crates and async/network dependencies replaced with single unified hl7v2 dependency (v1.2.0, path="../hl7v2") with network feature enabled and default-features disabled; dev-dependencies reduced to workspace-managed tokio, tokio-util, bytes.
Deprecation messaging
crates/hl7v2-network/README.md
README updated to mark hl7v2-network as a deprecated compatibility crate for TCP/MLLP communication, directing new users to hl7v2::transport::network.
Re-export wrapper
crates/hl7v2-network/src/lib.rs
Crate transformed from full documentation hub and explicit module re-exports into minimal compatibility shim that re-exports all public APIs via wildcard from hl7v2::transport::network.
Core module definitions
crates/hl7v2-network/src/codec.rs, src/client.rs, src/server.rs
MLLP codec provides frame start/end detection and size enforcement; async client manages TCP connection, message send/receive with timeouts; async server binds TCP listener, accepts connections, delegates message handling via trait, sends ACKs per timing policy.
Module unit tests
crates/hl7v2-network/src/codec.rs, src/client.rs, src/server.rs
Embedded unit tests validate codec framing/junk/size behavior, client builder configuration and disconnected state, and server bind/local_addr lifecycle.
Test utilities migration
crates/hl7v2-network/tests/common/mod.rs
Test helper structs updated to import Message and Error from unified hl7v2 crate instead of separate hl7v2_model; all MessageHandler implementations updated to use Result<Option<Message>, Error> return type.
Comprehensive test suite
crates/hl7v2-network/src/tests.rs
New extensive test suite covers codec encode/decode with framing/junk/size limits, client configuration/timeouts/disconnect, server lifecycle/ACK timing policies, property-based roundtrip/no-panic validation, and end-to-end integration tests with concurrent clients and partial frame handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A network wrapped in shim so neat,
Old code finds its new retreat,
Tests now sing in unified voice,
Transport consolidated by choice,
Deprecation done with gentle grace!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main refactoring objective: converting hl7v2-network into a compatibility shim.
Description check ✅ Passed The description provides a clear summary of changes, specific validation steps, and aligns well with the PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/hl7v2-network-compat-shim

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Microsoft Presidio Analyzer (2.2.362)
crates/hl7v2-network/Cargo.toml

Microsoft Presidio Analyzer failed to scan this file


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
crates/hl7v2-network/Cargo.toml (2)

8-8: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update description to reflect deprecation.

The description still advertises a full implementation ("HL7 v2 MLLP network client and server (TCP/TLS)") for a crate that is now a thin re-export shim.

🔧 Proposed fix
-description = "HL7 v2 MLLP network client and server (TCP/TLS)"
+description = "Deprecated compatibility shim; use hl7v2::transport::network instead"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/hl7v2-network/Cargo.toml` at line 8, Update the Cargo.toml description
value to indicate this crate is deprecated and is a thin re-export shim rather
than a full implementation; locate the description field (description = "HL7 v2
MLLP network client and server (TCP/TLS)") and change its text to something like
"Deprecated: thin re-export shim for HL7 v2 MLLP networking (no full
client/server implementation)" so users see the deprecation and limited scope.

8-8: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

description still advertises a full implementation — update to reflect deprecation.

The description "HL7 v2 MLLP network client and server (TCP/TLS)" describes the former standalone crate, not the thin re-export shim it now is. crates.io and tooling will surface this description to users evaluating migration.

-description = "HL7 v2 MLLP network client and server (TCP/TLS)"
+description = "Deprecated compatibility shim for hl7v2-network; use hl7v2::transport::network instead"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/hl7v2-network/Cargo.toml` at line 8, Update the Cargo.toml description
value which currently reads "HL7 v2 MLLP network client and server (TCP/TLS)" to
state that this crate is a deprecated thin re-export/shim (for example:
"Deprecated: thin re-export shim for HL7 v2 MLLP network types; use
<new-crate-name>"), so that crates.io and tooling reflect deprecation; modify
the description key in crates/hl7v2-network/Cargo.toml accordingly.
crates/hl7v2-network/tests/common/mod.rs (2)

252-260: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove the phantom handler parameter — every test creates a fresh handler for server.run() anyway.

The _handler parameter is consumed but never used. Every call site follows the same pattern: pass a handler to start_test_server, then immediately spawn server.run() with a new instance of the same handler type. The parameter is wasted, and since MllpServer has no set_handler method, there's no way to register it.

🔧 Remove the unused parameter
-pub async fn start_test_server<H: MessageHandler + 'static>(
-    _handler: H,
-) -> (MllpServer, SocketAddr) {
+pub async fn start_test_server() -> (MllpServer, SocketAddr) {
     let mut server = MllpServer::new(MllpServerConfig::default());
     let bind_addr: SocketAddr = "127.0.0.1:0".parse().unwrap();
     server.bind(bind_addr).await.expect("Failed to bind server");
     let addr = server.local_addr().expect("Failed to get server address");
     (server, addr)
 }

Update all call sites to omit the handler argument since it's created fresh in each test's server.run() call anyway.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/hl7v2-network/tests/common/mod.rs` around lines 252 - 260, Remove the
unused phantom parameter _handler from the start_test_server function signature
(it implements MessageHandler but is never used) and adjust its implementation
to not accept or reference that parameter; update all call sites that currently
pass a handler to start_test_server to call it with no argument and continue to
spawn server.run() with freshly created handler instances as they already do
(references: start_test_server, MessageHandler, MllpServer, server.run()).

252-260: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

The _handler parameter to start_test_server is unused and should be removed.

It is never registered with the server or used in any way. Every test passes a handler to start_test_server, then immediately passes a different (or fresh) handler to server.run(), ignoring the first parameter entirely. Remove the generic type parameter and argument to simplify the API.

🔧 Suggested change
-pub async fn start_test_server<H: MessageHandler + 'static>(
-    _handler: H,
-) -> (MllpServer, SocketAddr) {
+pub async fn start_test_server() -> (MllpServer, SocketAddr) {
     let mut server = MllpServer::new(MllpServerConfig::default());
     let bind_addr: SocketAddr = "127.0.0.1:0".parse().unwrap();
     server.bind(bind_addr).await.expect("Failed to bind server");
     let addr = server.local_addr().expect("Failed to get server address");
     (server, addr)
 }

Then update all 20+ call sites to remove the handler argument.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/hl7v2-network/tests/common/mod.rs` around lines 252 - 260, Remove the
unused generic parameter and parameter from start_test_server: delete the
generic bound "<H: MessageHandler + 'static>" and the "_handler: H" argument in
the function signature so start_test_server is no longer generic or accepting a
handler, and update its body to simply create, bind, and return the MllpServer
and SocketAddr (keep use of MllpServer::new, MllpServerConfig::default, bind,
and local_addr). Then update all call sites that currently pass a handler to
start_test_server to call it with no handler argument and continue to register
their handler when they call server.run(...). This removes the unused
MessageHandler reference and simplifies the API while preserving MllpServer
usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/hl7v2-network/README.md`:
- Line 3: Summary: The README uses "MLLP based" as a compound modifier and
should be hyphenated. Fix: update the sentence containing "TCP and MLLP based
network communication." (search for that exact string in the README or the line
under the crate description) and change it to "TCP and MLLP-based network
communication." to correctly hyphenate the compound modifier "MLLP-based".
- Line 3: Update the README phrase "MLLP based" to the hyphenated compound
modifier "MLLP-based" so the sentence reads "Deprecated compatibility crate for
TCP and MLLP-based network communication"; locate and replace the unhyphenated
instance in the README content where the crate description is defined.

In `@crates/hl7v2-network/src/lib.rs`:
- Around line 1-5: Replace the glob re-export `pub use
hl7v2::transport::network::*;` with explicit, per-item re-exports annotated with
#[deprecated(...)] so consumers get compile-time deprecation warnings; enumerate
every public item from hl7v2::transport::network (e.g., MllpClient, MllpServer,
and any other structs/functions/traits) and add lines like #[deprecated(since =
"1.2.0", note = "Use `hl7v2::transport::network::MllpClient` instead")] pub use
hl7v2::transport::network::MllpClient; repeating for each public symbol so the
compiler emits deprecation diagnostics guiding migration.
- Around line 1-5: The glob re-export `pub use hl7v2::transport::network::*`
cannot emit `#[deprecated]` warnings to downstream users; replace the wildcard
with explicit per-item re-exports and annotate each with `#[deprecated(note =
"Use hl7v2::transport::network::... instead")]` (or similar) so consumers see
migration warnings for each of the nine items: MllpClient, MllpClientBuilder,
MllpClientConfig, MllpCodec, AckTimingPolicy, MessageHandler, MllpConnection,
MllpServer, and MllpServerConfig; update the crate-level docs as needed and keep
the items re-exported from `hl7v2::transport::network` but written individually
with the deprecation attribute to ensure compiler warnings are emitted.

---

Outside diff comments:
In `@crates/hl7v2-network/Cargo.toml`:
- Line 8: Update the Cargo.toml description value to indicate this crate is
deprecated and is a thin re-export shim rather than a full implementation;
locate the description field (description = "HL7 v2 MLLP network client and
server (TCP/TLS)") and change its text to something like "Deprecated: thin
re-export shim for HL7 v2 MLLP networking (no full client/server
implementation)" so users see the deprecation and limited scope.
- Line 8: Update the Cargo.toml description value which currently reads "HL7 v2
MLLP network client and server (TCP/TLS)" to state that this crate is a
deprecated thin re-export/shim (for example: "Deprecated: thin re-export shim
for HL7 v2 MLLP network types; use <new-crate-name>"), so that crates.io and
tooling reflect deprecation; modify the description key in
crates/hl7v2-network/Cargo.toml accordingly.

In `@crates/hl7v2-network/tests/common/mod.rs`:
- Around line 252-260: Remove the unused phantom parameter _handler from the
start_test_server function signature (it implements MessageHandler but is never
used) and adjust its implementation to not accept or reference that parameter;
update all call sites that currently pass a handler to start_test_server to call
it with no argument and continue to spawn server.run() with freshly created
handler instances as they already do (references: start_test_server,
MessageHandler, MllpServer, server.run()).
- Around line 252-260: Remove the unused generic parameter and parameter from
start_test_server: delete the generic bound "<H: MessageHandler + 'static>" and
the "_handler: H" argument in the function signature so start_test_server is no
longer generic or accepting a handler, and update its body to simply create,
bind, and return the MllpServer and SocketAddr (keep use of MllpServer::new,
MllpServerConfig::default, bind, and local_addr). Then update all call sites
that currently pass a handler to start_test_server to call it with no handler
argument and continue to register their handler when they call server.run(...).
This removes the unused MessageHandler reference and simplifies the API while
preserving MllpServer usage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f399c68d-29b0-473a-b999-a095924d0bce

📥 Commits

Reviewing files that changed from the base of the PR and between 9ab383c and ecd4d78.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • crates/hl7v2-network/Cargo.toml
  • crates/hl7v2-network/README.md
  • crates/hl7v2-network/src/client.rs
  • crates/hl7v2-network/src/codec.rs
  • crates/hl7v2-network/src/lib.rs
  • crates/hl7v2-network/src/server.rs
  • crates/hl7v2-network/src/tests.rs
  • crates/hl7v2-network/tests/common/mod.rs
💤 Files with no reviewable changes (4)
  • crates/hl7v2-network/src/client.rs
  • crates/hl7v2-network/src/tests.rs
  • crates/hl7v2-network/src/codec.rs
  • crates/hl7v2-network/src/server.rs

# hl7v2-network

TCP and MLLP based network communication for HL7 v2.
Deprecated compatibility crate for TCP and MLLP based network communication.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Hyphenate "MLLP-based" (compound modifier).

-Deprecated compatibility crate for TCP and MLLP based network communication.
+Deprecated compatibility crate for TCP and MLLP-based network communication.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Deprecated compatibility crate for TCP and MLLP based network communication.
Deprecated compatibility crate for TCP and MLLP-based network communication.
🧰 Tools
🪛 LanguageTool

[grammar] ~3-~3: Use a hyphen to join words.
Context: ...ted compatibility crate for TCP and MLLP based network communication. Use `hl7v2:...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/hl7v2-network/README.md` at line 3, Summary: The README uses "MLLP
based" as a compound modifier and should be hyphenated. Fix: update the sentence
containing "TCP and MLLP based network communication." (search for that exact
string in the README or the line under the crate description) and change it to
"TCP and MLLP-based network communication." to correctly hyphenate the compound
modifier "MLLP-based".

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Hyphenate compound modifier: "MLLP-based".

MLLP based acting as a compound adjective before network communication should be hyphenated.

-Deprecated compatibility crate for TCP and MLLP based network communication.
+Deprecated compatibility crate for TCP and MLLP-based network communication.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Deprecated compatibility crate for TCP and MLLP based network communication.
Deprecated compatibility crate for TCP and MLLP-based network communication.
🧰 Tools
🪛 LanguageTool

[grammar] ~3-~3: Use a hyphen to join words.
Context: ...ted compatibility crate for TCP and MLLP based network communication. Use `hl7v2:...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/hl7v2-network/README.md` at line 3, Update the README phrase "MLLP
based" to the hyphenated compound modifier "MLLP-based" so the sentence reads
"Deprecated compatibility crate for TCP and MLLP-based network communication";
locate and replace the unhyphenated instance in the README content where the
crate description is defined.

Comment on lines +1 to +5
//! Deprecated compatibility crate.
//!
//! Use `hl7v2::transport::network` instead.

pub use hl7v2::transport::network::*;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does Rust stable support #[deprecated] on a glob pub use re-export statement?

💡 Result:

No, Rust stable does not support applying #[deprecated] to a glob pub use re-export statement (e.g., #[deprecated] pub use other::*;) such that it causes warnings for downstream users who use the re-exported items. The attribute is accepted syntactically but has no effect on consumers; the deprecation does not propagate.[1][2][3][4][5] Official Rust documentation on the #[deprecated] attribute states it applies to items like functions, types, etc., but does not mention use declarations or re-exports.[6][7] Long-standing issues confirm that #[deprecated] on pub use (including examples like pub use a_module::ActiveType) does not warn users.[2][3] This applies equally to glob re-exports (pub use *), as globs expand to individual re-exports during name resolution, inheriting the same limitation.[1][8] Recent developments (as of 2026): A lint was proposed and rebased to error on #[deprecated] pub use, warning developers it "has no effect" (using #[deny(useless_deprecated)]), confirming the feature is still unsupported.[1][4] The core issue #30827 remains open, with plans discussed but blocked until implementation.[1][2] No evidence of support in stable Rust releases up to the current date.[5][9] Workarounds include deprecated shims (e.g., #[deprecated] pub type Alias = Original;) or individual deprecations where feasible, but not for globs.[2][10]

Citations:


Add compiler-level deprecation warnings to guide migration.

The module documentation states "deprecated" as prose, but without #[deprecated] attributes, consumers of hl7v2_network::* will compile silently without any deprecation diagnostics. The migration goal won't be enforced by the compiler.

Unfortunately, Rust stable does not support #[deprecated] on glob pub use re-exports (e.g., pub use hl7v2::transport::network::*;). The attribute is accepted syntactically but produces no effect on consumers, and this applies equally to non-glob pub use statements. The only stable workaround is to explicitly list and re-export each public item:

#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpClient` instead")]
pub use hl7v2::transport::network::MllpClient;

#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpServer` instead")]
pub use hl7v2::transport::network::MllpServer;
// … and so on for each public item

This requires identifying and listing all public items from hl7v2::transport::network.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/hl7v2-network/src/lib.rs` around lines 1 - 5, Replace the glob
re-export `pub use hl7v2::transport::network::*;` with explicit, per-item
re-exports annotated with #[deprecated(...)] so consumers get compile-time
deprecation warnings; enumerate every public item from hl7v2::transport::network
(e.g., MllpClient, MllpServer, and any other structs/functions/traits) and add
lines like #[deprecated(since = "1.2.0", note = "Use
`hl7v2::transport::network::MllpClient` instead")] pub use
hl7v2::transport::network::MllpClient; repeating for each public symbol so the
compiler emits deprecation diagnostics guiding migration.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# List all public items exported from hl7v2::transport::network to enumerate what needs explicit re-exports
rg -n 'pub (struct|enum|trait|type|fn|const|static|use)' --type rs -A 1 \
    $(fd 'mod.rs\|network.rs' --type f | xargs grep -l 'transport' 2>/dev/null | head -5)

Repository: EffortlessMetrics/hl7v2-rs

Length of output: 97


🏁 Script executed:

# First, find and examine the actual file
cat -n crates/hl7v2-network/src/lib.rs

Repository: EffortlessMetrics/hl7v2-rs

Length of output: 229


🏁 Script executed:

# Find the hl7v2::transport::network module
fd -type f -name "*.rs" | xargs rg -l "transport.*network" | head -10

Repository: EffortlessMetrics/hl7v2-rs

Length of output: 585


🏁 Script executed:

# Let's find network-related modules more broadly
fd -type f -path "*/transport/*" -name "*.rs"

Repository: EffortlessMetrics/hl7v2-rs

Length of output: 241


🏁 Script executed:

# Read the source module to see what's publicly exported
cat -n crates/hl7v2/src/transport/network/mod.rs

Repository: EffortlessMetrics/hl7v2-rs

Length of output: 3321


🏁 Script executed:

# Check the codec file too since it was referenced
wc -l crates/hl7v2/src/transport/network/codec.rs

Repository: EffortlessMetrics/hl7v2-rs

Length of output: 118


🌐 Web query:

#[deprecated] on glob re-export pub use Rust compiler behavior rust-lang/rust

💡 Result:

In Rust, the #[deprecated] attribute applied directly to a pub use statement (whether a specific item re-export or a glob re-export like pub use other::) has no effect on users consuming the re-exported item. Users will not receive deprecation warnings when using the re-exported items, even if the original items are deprecated[1][2][3]. The deprecation check occurs during name resolution on the original definition's DefId, not propagated through re-exports[1]. This behavior has been consistent since at least 2018 and remains unchanged as of 2026[4][5]. For glob re-exports specifically (pub use other::), the attribute cannot be applied directly to individual items within the glob; it would apply to the use statement itself, which is ineffective as described[6][7]. Attributes on glob imports are generally ignored for the imported items, similar to rustdoc inlining rules[8]. Recent proposals to add a useless_deprecated lint (deny by default) to warn library authors when #[deprecated] is placed on pub use statements were not merged (PRs #132038 and #142731 closed without landing)[2][5]. The existing useless_deprecated lint detects other ineffective cases like on impl blocks but not re-exports[9]. Workaround for deprecating a re-export: Create a deprecated shim (e.g., a function or type alias) instead of using pub use[10][3]. Full support for propagating #[deprecated] through re-exports is planned but blocked[5][3]. Official docs confirm #[deprecated] applies to items but do not address re-export propagation[11].

Citations:


🏁 Script executed:

# Double-check for any other public items exported from submodules (especially codec)
rg 'pub (struct|enum|trait|type|fn|const)' crates/hl7v2/src/transport/network/ -A 0 | head -20

Repository: EffortlessMetrics/hl7v2-rs

Length of output: 1864


The glob re-export cannot emit #[deprecated] compiler warnings — users won't be prompted to migrate.

Marking a re-export (pub use) with #[deprecated] does not produce a warning for consumers — this is a long-standing Rust compiler limitation affecting all re-exports. The glob form (pub use hl7v2::transport::network::*) prevents even per-item annotations from working, as attributes cannot be applied to wildcards.

Downstream crates using hl7v2_network::MllpClient (or any of the 9 re-exported items: MllpClient, MllpClientBuilder, MllpClientConfig, MllpCodec, AckTimingPolicy, MessageHandler, MllpConnection, MllpServer, MllpServerConfig) will compile silently with no migration nudge. The deprecation exists only in prose documentation.

The only reliable workaround is explicit per-item re-exports, each annotated with #[deprecated]:

🔧 Proposed fix — explicit re-exports with #[deprecated]
-//! Deprecated compatibility crate.
-//!
-//! Use `hl7v2::transport::network` instead.
-
-pub use hl7v2::transport::network::*;
+//! Deprecated compatibility crate.
+//!
+//! Use [`hl7v2::transport::network`] instead.
+
+#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpClient` instead")]
+pub use hl7v2::transport::network::MllpClient;
+
+#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpClientBuilder` instead")]
+pub use hl7v2::transport::network::MllpClientBuilder;
+
+#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpClientConfig` instead")]
+pub use hl7v2::transport::network::MllpClientConfig;
+
+#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpCodec` instead")]
+pub use hl7v2::transport::network::MllpCodec;
+
+#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::AckTimingPolicy` instead")]
+pub use hl7v2::transport::network::AckTimingPolicy;
+
+#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MessageHandler` instead")]
+pub use hl7v2::transport::network::MessageHandler;
+
+#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpConnection` instead")]
+pub use hl7v2::transport::network::MllpConnection;
+
+#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpServer` instead")]
+pub use hl7v2::transport::network::MllpServer;
+
+#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpServerConfig` instead")]
+pub use hl7v2::transport::network::MllpServerConfig;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
//! Deprecated compatibility crate.
//!
//! Use `hl7v2::transport::network` instead.
pub use hl7v2::transport::network::*;
//! Deprecated compatibility crate.
//!
//! Use [`hl7v2::transport::network`] instead.
#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpClient` instead")]
pub use hl7v2::transport::network::MllpClient;
#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpClientBuilder` instead")]
pub use hl7v2::transport::network::MllpClientBuilder;
#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpClientConfig` instead")]
pub use hl7v2::transport::network::MllpClientConfig;
#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpCodec` instead")]
pub use hl7v2::transport::network::MllpCodec;
#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::AckTimingPolicy` instead")]
pub use hl7v2::transport::network::AckTimingPolicy;
#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MessageHandler` instead")]
pub use hl7v2::transport::network::MessageHandler;
#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpConnection` instead")]
pub use hl7v2::transport::network::MllpConnection;
#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpServer` instead")]
pub use hl7v2::transport::network::MllpServer;
#[deprecated(since = "1.2.0", note = "Use `hl7v2::transport::network::MllpServerConfig` instead")]
pub use hl7v2::transport::network::MllpServerConfig;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/hl7v2-network/src/lib.rs` around lines 1 - 5, The glob re-export `pub
use hl7v2::transport::network::*` cannot emit `#[deprecated]` warnings to
downstream users; replace the wildcard with explicit per-item re-exports and
annotate each with `#[deprecated(note = "Use hl7v2::transport::network::...
instead")]` (or similar) so consumers see migration warnings for each of the
nine items: MllpClient, MllpClientBuilder, MllpClientConfig, MllpCodec,
AckTimingPolicy, MessageHandler, MllpConnection, MllpServer, and
MllpServerConfig; update the crate-level docs as needed and keep the items
re-exported from `hl7v2::transport::network` but written individually with the
deprecation attribute to ensure compiler warnings are emitted.

@EffortlessSteven EffortlessSteven merged commit 4d44124 into main May 7, 2026
21 checks passed
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.

1 participant