phobos-sys-exttypes ~master
Candidate types for inclusion in Phobos 3.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Phobos ExtTypes (phobos-sys-exttypes)
A collection of compact, storage-oriented value types for the D programming language. This project provides zero-dependency implementations of common data types designed for eventual integration into the upcoming Phobos 3 standard library.
The types in this library prioritize efficient storage, fast parsing, and maximum compatibility with D's functional attributes (@safe, pure, nothrow, @nogc, and CTFE).
Features
- Decimal: IEEE 754-2008 compliant decimal floating-point arithmetic (
Decimal32,Decimal64,Decimal128) using BID encoding. - Network Addresses: Value types for IP and hardware addresses, including
IPv4Address,IPv6Address,IPAddress(tagged union), CIDR networks (IPv4Network,IPv6Network),MACAddress(EUI-48), andEUI64Address. - SemVer: A fully-compliant Semantic Versioning 2.0.0 type (
SemVer) that provides correct precedence ordering, fast parsing, and formatting.
Installation
Add this project as a dependency to your DUB project via the command line:
dub add phobos-sys-exttypes
Or manually add it to your dub.sdl:
dependency "phobos-sys-exttypes" version="~>0.1.0"
Or dub.json:
"dependencies": {
"phobos-sys-exttypes": "~>0.1.0"
}
Examples
Decimal Floating-Point
import phobos.sys.decimal;
void main() {
Decimal64 d1, d2;
Decimal64.fromString("123.45", d1);
Decimal64.fromString("0.05", d2);
Decimal64 sum = d1 + d2;
assert(sum.toString() == "123.50");
}
Network Addresses
import phobos.sys.network;
void main() {
// IPv4
auto localhost = IPv4Address(127, 0, 0, 1);
assert(localhost.isLoopback());
// IPv6 parsing with zero compression
IPv6Address ip6;
if (IPv6Address.fromString("2001:db8::1", ip6)) {
assert(ip6.toString() == "2001:db8::1");
}
// MAC Addresses
MACAddress mac;
MACAddress.fromString("00:1A:2B:3C:4D:5E", mac);
assert(mac.toEUI64().toString() == "02:1a:2b:ff:fe:3c:4d:5e");
}
Semantic Versioning
import phobos.sys.semver;
void main() {
SemVer v1, v2;
SemVer.fromString("1.0.0-rc.1", v1);
SemVer.fromString("1.0.0", v2);
// Precedence comparison
assert(v1 < v2);
// Construct manually
auto v3 = SemVer(2, 0, 0, "alpha.1", "build.123");
assert(v3.toString() == "2.0.0-alpha.1+build.123");
}
Contribution Guidelines
Contributions are welcome! If you'd like to improve the library, please keep the following guidelines in mind:
- No standard library dependencies: The core implementations should not depend on
std.*modules to keep it easy to integrate into Phobos v3. - Strict attributes: Attempt to make functions
@safe pure nothrow @nogcand CTFE-compatible wherever possible. (e.g.,toString()generally allocates, butfromString()and core operations should not). - Tests & Coverage: Maintain high test coverage using D's built-in
unittestblocks. New features require tests. - AI/LLM Contributions: Any LLM (Large Language Model) based contributions must include the Prompt used to generate the contribution in the `PROMPTS.txt` file.
To submit a contribution:
- Fork the repository
- Create your feature branch (
git checkout -b feature/my-new-feature) - Commit your changes. (If using an LLM, remember to update
PROMPTS.txt) - Push to the branch (
git push origin feature/my-new-feature) - Open a Pull Request
License
This project is licensed under the Boost Software License 1.0 (BSL-1.0). See the LICENSE file for details.
- ~master released 13 days ago
- LightBender/phobos.sys.exttypes
- BSL-1.0
- Copyright © 2026, Adam Wilson
- Authors:
- Dependencies:
- none
- Versions:
-
Show all 2 versions1.0.0 2026-Jun-01 ~master 2026-Jun-01 - Download Stats:
-
-
2 downloads today
-
3 downloads this week
-
5 downloads this month
-
5 downloads total
-
- Score:
- 0.1
- Short URL:
- phobos-sys-exttypes.dub.pm