2 releases
0.1.1 | Jun 27, 2024 |
---|---|
0.1.0 | Apr 27, 2024 |
#922 in Parser implementations
Used in pakige
22KB
451 lines
deb-version(7)
This is a Rust port of the version-related code in dpkg
, the
base layer of package management in Debian. The goal is to match the behavior of dpkg as closely as
possible, while providing convenient Rust abstractions. The specification can be found in the
deb-version(7)
man page.
Functionality
You can parse and validate versions, as well as check equality and sort in the same way dpkg would.
use deb_version7::DebVersion;
use std::str::FromStr;
let first = DebVersion::from_str("1.0.0-1").unwrap();
let second = DebVersion::from_str("1.0.0-1~bpo12+1").unwrap();
assert!(first > second);
While the DebVersion
is created using the Rust String
/&str
type, deb versions are ASCII-only. Any non-ASCII characters
will be immediately rejected.
Implementation
The port was done using version f268c3733 of the dpkg Git repository.
The rough structure of the upstream C code was retained to ease future updates. No effort has been made into evaluating performance (yet).
Credits
deb-version7
is available under the GPL v3, or at your option, any later version. The
primary copyright holders are Ian Jackson and Guillem Jover, who wrote the original C code.
Kunal Mehta (with the assistance of ChatGPT 3.5) did the Rust port.
Each source file contains where the code originally came from in the dpkg codebase retains the required license headers (with minimal syntax changes).
Dependencies
~290–750KB
~18K SLoC