Feat/rust nif datetime poc#142
Open
lupodevelop wants to merge 2 commits into
Open
Conversation
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.
What
Replace Timex with the Elixir stdlib in
Arke.Utils.DatetimeHandler, and moveISO8601 parsing and month shifting to a Rust NIF (
Arke.Native.DateParser).If the NIF isn't loaded, parsing and shifting fall back to pure Elixir, so
runtime behaviour is the same with or without the native lib.
Why
Timex pulled in tzdata (and its runtime auto-update) for what is mostly ISO
parsing and
now. The stdlib covers all of it now. The NIF also doescalendar-correct month shifting, which the stdlib doesn't do on its own.
This is also the first Rust component: the build, cross-compiled release
binaries, fallback and tests are set up so future native pieces are cheap to add.
Breaking changes
format/2now only supports ISO extended/basic, not arbitrary Timex formatstrings. Only
{ISO:Basic:Z}and the default are used in this repo, sointernal callers are unaffected.
or Timex.from_unix(...)branch in apple.ex). Companion PRCI
CI will be red on this PR. For fork PRs GitHub runs the base branch workflows,
which don't have a Rust step yet, so the NIF won't compile. The Rust setup is in
this diff (ci.yml + native.yml + release.yml) and is green once on main.
Distribution
Binaries are built by
release.ymlon tag and published to the GitHub release;rustler_precompileddownloads them so users don't need Rust.Bootstrap: this version builds from source (
force_builddefaults true), so theRust toolchain is required to compile until the first tagged release exists.
After that release, commit the generated checksum and flip
force_buildtofalse. From then on it's download-only, no Rust needed downstream.
Tests
mix test test/utils/datetime_handler_test.exsgolden cases plus randomizedruns checking NIF output against the stdlib parser and against plain-Elixir
month math.
cargo fmt/clippy/testrun in native.yml.