refactor(eventhubs)!: harden public API for 1.0 (non_exhaustive + TryFrom)#4722
Draft
j7nw4r wants to merge 1 commit into
Draft
refactor(eventhubs)!: harden public API for 1.0 (non_exhaustive + TryFrom)#4722j7nw4r wants to merge 1 commit into
j7nw4r wants to merge 1 commit into
Conversation
…From) These are deliberate breaking changes intended to land before the 1.0.0 API freeze, since they cannot be made afterward without a major bump. Mark the crate's public data, options, and error types `#[non_exhaustive]` so fields and variants can be added post-1.0 without breaking downstream code: the `MessageId`, `StartLocation`, and `ProcessorStrategy` enums; the `SendBatchOptions`, `SendEventOptions`, `SendMessageOptions`, `AddEventDataOptions`, `EventDataBatchOptions`, `OpenReceiverOptions`, `StartPosition`, and `RetryOptions` options structs; and the `EventHubProperties`, `EventHubPartitionProperties`, `Checkpoint`, `Ownership`, `StartPositions`, and `EventHubsError` data structs. `AddEventDataOptions` gains a `Default` derive so external code retains a construction path. Convert the four panicking `MessageId` conversions from `From` to `TryFrom`. `Uuid`, `Vec<u8>`, `String`, and `u64` now implement `TryFrom<MessageId>` returning `Result<_, EventHubsError>` instead of a `From` impl that panicked on a non-matching variant. The infallible conversions into `MessageId`, and between `MessageId` and `AmqpMessageId`, are unchanged. Update the crate's doc examples, tests, examples, and benchmark to construct the now-non_exhaustive structs via `Default::default()` plus public-field assignment, and record both changes in the CHANGELOG.
j7nw4r
force-pushed
the
j7nw4r/eventhubs-api-hardening-1.0
branch
from
July 8, 2026 22:09
82258b9 to
8488f3a
Compare
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.
Summary
This is a BREAKING change to
azure_messaging_eventhubs, intended to land before the 1.0.0 API freeze. It marks the crate's public data, options, and error types#[non_exhaustive]and converts four panickingMessageIdconversions fromFromtoTryFrom. Neither change can be made after 1.0 without a major version bump, so they are grouped here as pre-1.0 hardening.Motivation
#[non_exhaustive]lets new fields and enum variants be added after 1.0 without breaking downstream code, which is not possible once the public surface is frozen. The fourFrom<MessageId>impls that producedUuid,Vec<u8>,String, andu64panicked whenever theMessageIdvariant did not match the requested target type, putting a panic on an infallible-looking conversion in the public API;TryFromsurfaces the mismatch as a recoverable error instead.Changes
#[non_exhaustive]to theMessageId,StartLocation, andProcessorStrategyenums; theSendBatchOptions,SendEventOptions,SendMessageOptions,AddEventDataOptions,EventDataBatchOptions,OpenReceiverOptions,StartPosition, andRetryOptionsoptions structs; and theEventHubProperties,EventHubPartitionProperties,Checkpoint,Ownership,StartPositions, andEventHubsErrordata structs.ErrorKindandConnectionStringalready had it.Defaultderive toAddEventDataOptionsso external code keeps a construction path now that the empty struct literal is no longer usable outside the crate. The other affected structs already derived or implementedDefault.Uuid,Vec<u8>,String, andu64to implementTryFrom<MessageId>(withError = EventHubsError) instead ofFrom<MessageId>. The error reuses the crate's existingEventHubsErrortype to keep the public error surface unified. The infallible conversions intoMessageId, and betweenMessageIdandAmqpMessageId, remainFrom.Default::default()plus public-field assignment, since struct-literal and functional-record-update construction and exhaustive enum matching are no longer available to external code.## 0.15.0 (Unreleased)in the CHANGELOG.Validation
cargo build -p azure_messaging_eventhubs --all-features: passcargo clippy -p azure_messaging_eventhubs --all-targets --all-features -- -D warnings: passcargo test -p azure_messaging_eventhubs --all-features: pass (offline unit and doc tests; live#[recorded::test(live)]tests self-skip without credentials)cargo fmt -p azure_messaging_eventhubs -- --check: clean