Skip to content

API index

The public symbols of sparkles:versions, by module. This page is a lookup table; for the concepts behind it see the concepts reference, and for the normative definitions the SPEC (§12 lists the same surface).

There are three import patterns:

  • Single scheme. Import just the scheme module and the parse types: sparkles.versions.schemes.semver : SemVer, sparkles.versions.parsing : ParseMode, sparkles.base.text.errors : ParseError.
  • Polyglot package import. import sparkles.versions; re-exports the concepts, parse types, Ranges, the operations, the VERS/pURL interop, the sum types, and every shipped scheme.
  • Scheme author. Import the concepts and Ranges from sparkles.versions.traits / .ranges and the parse vocabulary from sparkles.base.text.errors, then static assert conformance.

sparkles.versions

The package module (package.d). Publicly re-exports traits, parsing, ranges, operations, vers, purl, any, and schemes; under version(unittest) it also re-exports testing.

sparkles.versions.traits

The three concepts and the optional-capability vocabulary.

SymbolDescription
isVersion!TRequired version surface: three-way opCmp + output-range toString.
isVersionRange!RRequired range set-algebra basis (empty, singleton, complement, intersection, contains).
isVersionScheme!SA version type that also carries purlType and a static parse.
hasOrderKey!TTrue when .orderKey is an unsigned integer (fast-path compare/sort).
OrderKeyType!TThe unsigned type .orderKey returns; valid only when hasOrderKey!T.
supportsPrerelease!TTrue when .isPrerelease is a bool (gates the prerelease-in-range rule).
hasComponents!TTrue when T.components is a non-empty string[] of unsigned-int field names.
hasSemVerComponents!TTrue when components begins ["major","minor","patch"] (gates caret/tilde).
hasBuildMetadata!TTrue when .build is const(char)[].
supportsNativeRange!STrue when the scheme has parseNativeRange.
supportsLooseParse!STrue when the scheme has parseLoose.
componentCount!TT.components.length.
ulong componentAt(T)(in T v, size_t i)The i-th component read as a ulong.
int compareComponents(T)(in T a, in T b)Three-way compare of the component list, most-significant first.

sparkles.versions.parsing

The parse-mode selector; re-exports the generic parse types from sparkles.base.text.errors.

SymbolDescription
ParseMode { strict, loose }Strict/loose selector for parsers that share one code path.
ParseError, ParseErrorCode, ParseExpected!TRe-exported parse vocabulary (see base.text.errors below).

sparkles.versions.ranges

The single generic range type.

SymbolDescription
Ranges!VSorted, disjoint interval set over any isVersion!V.
Ranges.empty() / full()The empty / universal set.
Ranges.singleton(V v)The set {v}.
complement(), intersection(in Ranges), union_(in Ranges)Set algebra.
contains(in V v)Membership test.
isDisjoint(in Ranges), subsetOf(in Ranges)Derived relations.
higherThan(V), strictlyHigherThan(V), lowerThan(V), strictlyLowerThan(V), between(V lo, V hi)Interval constructors.
opEquals(in Ranges)Compares canonical (sorted, merged) interval sequences.
void toString(W)(ref W w)Emits VERS constraint syntax.

sparkles.versions.operations

Generic algorithms, each pairing a required-surface baseline with an optional fast path.

SymbolDescription
int order(T)(in T a, in T b)Three-way compare; takes the orderKey fast path when available.
T[] sort(T)(T[] versions)Sorts a slice ascending in place (radix when hasOrderKey, else comparison).
bool satisfies(T)(const T v, in Ranges!T range)Version-in-range, with the prerelease-in-range rule when applicable.
Ranges!V caret(V)(in V v)^v[v, nextMajor); requires hasSemVerComponents!V.
Ranges!V tilde(V)(in V v)~v[v, nextMinor); requires hasSemVerComponents!V.
T truncateTo(string name, T)(in T v)Zeroes every component below name; requires hasComponents!T.

sparkles.versions.vers

VERS URI parsing/emission and constraint translation.

SymbolDescription
VersUri { string scheme; string[] constraints; }The parsed URI surface, constraints pre-split on |.
ParseExpected!VersUri parseVersUri(string s)Parse the URI surface only (prefix, scheme, splitting, normalisation).
void formatVersUri(W)(ref W w, in VersUri v)Render constraints in stored order (scheme-agnostic, not version-sorted).
ParseExpected!(Ranges!S) fromVersConstraint(S)(string segment)One <op><version> segment → a typed Ranges!S.
void toVersConstraint(S, W)(ref W w, in Ranges!S r)A Ranges!S → VERS constraint segments.
void formatVersAs(Scheme, W)(ref W w, in Ranges!(Scheme.Version) r)Canonical version-ordered emit under a known scheme.
string toVersUriStringAs(Scheme)(in Ranges!(Scheme.Version) r)Canonical emit to a freshly-allocated string.
parseVersAs!(Scheme)(string versUri)Static dispatch: parse a vers: URI to Scheme.Range.
ParseExpected!AnyRange parseVersAny(string versUri)Runtime dispatch on the URI scheme → AnyRange.

sparkles.versions.purl

Package-URL parsing and purl-type → scheme mapping. Consumes purls; does not generate them.

SymbolDescription
PackageUrl { string type, namespace, name, ver, subpath; string[string] qualifiers; }The parsed purl; ver is the raw, not-yet-parsed version string.
ParseExpected!PackageUrl parsePurl(string s)Parse a pkg: URI into a PackageUrl.
string purlTypeToSchemeName(string purlType)CTFE table folding purl types onto scheme names (e.g. packagistcomposer).
hasSchemeNameForPurlType(string purlType)static if-friendly probe behind purlTypeToSchemeName.
ParseExpected!AnyVersion parsePurlVersion(string purlUri)Parse a purl, resolve its type, and wrap the parsed version in AnyVersion.

sparkles.versions.any

Sum types for statically-unknown schemes, and partial comparison.

SymbolDescription
AnyVersionSumType over every shipped scheme version.
AnyRangeSumType over Ranges!S for every shipped scheme.
Nullable!int compareAny(in AnyVersion a, in AnyVersion b)Three-way compare; null across differing schemes (the defined contract).

sparkles.versions.schemes

Re-exports every scheme struct and the compile-time registry.

SymbolDescription
schemeForPurlType!(string purlType)Resolve a published pURL type to its scheme struct (compile error if none).
hasSchemeForPurlType!(string purlType)static if-friendly probe for the above.
allSchemesAliasSeq of every scheme, internal compact schemes included.
publishedSchemesallSchemes filtered to those with a real published pURL type.
publishedPurlTypesThe string[] of published pURL types.
publishedSchemeEntries, SchemePurlEntryThe published purl-type → scheme entry list used by dispatch.

Each scheme submodule exports one struct conforming to isVersion!T and isVersionScheme!S. See the scheme catalogue for the per-scheme detail (pURL type, examples, ordering rules, capabilities, native-range grammar, provenance).

ModuleStruct
sparkles.versions.schemes.semverSemVer
sparkles.versions.schemes.dmdDmd
sparkles.versions.schemes.dmd_compactDmdCompact
sparkles.versions.schemes.tinyTiny
sparkles.versions.schemes.calver_yymmCalVerYYMM
sparkles.versions.schemes.calver_yyyymmddCalVerYYYYMMDD
sparkles.versions.schemes.vimVimVer
sparkles.versions.schemes.pypiPypiVersion
sparkles.versions.schemes.mavenMavenVersion
sparkles.versions.schemes.debDebianVersion
sparkles.versions.schemes.genericGeneric

A conforming scheme provides alias Version, alias Range = Ranges!S, enum string purlType, and static ParseExpected!S parse(string); optionally parseLoose and parseNativeRange.

sparkles.versions.testing

Re-exported only under version(unittest). Test helpers such as checkParse and checkRoundTrip.

sparkles.base.text.errors

The generic, @nogc parse vocabulary reused by every Sparkles text parser.

SymbolDescription
ParseErrorCodeEnum of failure kinds (emptyInput, unexpectedCharacter, unexpectedEnd, leadingZero, numericOverflow, invalidIdentifier, widthMismatch, …).
ParseError { ParseErrorCode code; size_t offset; }A structured failure with a byte offset.
ParseExpected!TExpected!(T, ParseError, …): either a parsed T or a ParseError.

sparkles.base.text.readers

Slice-advance parser primitives (@nogc); useful when hand-writing a scheme's parse.

SymbolDescription
ParseExpected!T readInteger(T)(ref scope const(char)[] s)Read an unsigned integer of type T, advancing the slice.
size_t skipWhile(alias pred)(ref scope const(char)[] s)Skip leading chars matching pred; returns the count skipped.
bool tryConsume(ref scope const(char)[] s, char c)Consume c if present; report whether it was.
bool tryConsumeAny(ref scope const(char)[] s, scope const(char)[] set)Consume one char from set if present.
const(char)[] readUntil(ref scope const(char)[] s, scope const(char)[] delims)Take chars up to the first delimiter, advancing the slice.

sparkles.base.text.writers

Integer-formatting primitives (@nogc); useful when hand-writing a scheme's toString.

SymbolDescription
void writeInteger(Writer, T)(ref Writer w, const T val)Write an integer into an output range.
void writeIntegerPadded(Writer, T)(ref Writer w, const T val, size_t minDigits)Write an integer zero-padded to at least minDigits.

See also