buffa-types: add jiff feature (Timestamp/Duration conversions)#264
Open
macalinao wants to merge 3 commits into
Open
buffa-types: add jiff feature (Timestamp/Duration conversions)#264macalinao wants to merge 3 commits into
jiff feature (Timestamp/Duration conversions)#264macalinao wants to merge 3 commits into
Conversation
Add a `jiff` Cargo feature to buffa-types providing conversions between the protobuf well-known types and the jiff crate, mirroring the existing `chrono` feature: - Timestamp <-> jiff::Timestamp (reuses TimestampError; jiff's sign-consistent subsec nanos are re-normalized to proto's non-negative nanos convention by borrowing a second pre-epoch). - Duration <-> jiff::SignedDuration (new DurationJiffError with only InvalidNanos: SignedDuration's range is wide enough that a validated proto Duration never overflows it). no_std-compatible (jiff pulled with default-features=false + alloc); the std feature layers jiff/std on top. Wired into buffa-test for CI coverage. jiff 0.2 MSRV is 1.70, within buffa's 1.75 pin.
|
All contributors have signed the CLA ✍️ ✅ |
- Drop inline comments that restate the doc/code; keep the load-bearing underflow- and overflow-safety rationale. - Add a no_std jiff check to the check-nostd task (parity with chrono).
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
Adds a
jiffCargo feature tobuffa-typesproviding conversions between the protobuf well-known types andjiff, mirroring the existingchronofeature:Timestamp↔jiff::Timestamp— reuses the sharedTimestampError(InvalidNanos+Overflow).jiff::Timestampreports sub-second nanos sign-consistently (negative pre-epoch), so theFromimpl re-normalizes to proto's always-non-negativenanosconvention by borrowing a second.Duration↔jiff::SignedDuration—SignedDurationis the faithful analog of protoDuration(sign-consistentseconds+ sub-secondnanos;jiff::Spanis deliberately not a target since its calendar units have no fixed length). Introduces a narrowDurationJiffErrorwith onlyInvalidNanos: a validated protoDurationcan never overflowSignedDuration.Details
no_std-compatible:jiffis pulled withdefault-features = false+alloc;buffa-types'stdfeature layersjiff/stdon top viajiff?/std.buffa-testso the conversions are exercised bycargo test --workspacein CI (parity withchrono).jiff0.2 declares MSRV 1.70, within buffa's 1.75 pin (somsrv-checkstays green).jiff::Timestampextremes, bothSignedDurationextremes,i32::MINnanos, bidirectional sign-mismatch rejection.Checks
cargo test -p buffa-types --features jiff✅cargo clippy -p buffa-types --features jiff✅ (clean)cargo check -p buffa-types --no-default-features --features jiff✅ (no_std)cargo fmt --check✅.changes/unreleased/.