Skip to main content

Module version

Module version 

Source
Expand description

The two version grammars Mars reads and how a version is chosen among a repository’s tags.

A dependency entry’s version (see parse_constraint) and a package’s requires-mars / requires-meridian (satisfies_requirement) are different grammars: a bare 0.20 is the caret range ^0.20 in the first and >=0.20.0 in the second. Everything here is pure; the caller supplies the tag list and acts on the choice. choose is the whole decision: the binary runs its stages (settle, the lock check keeps_lock, then select) itself, because it replays the lock without listing tags, and selectVersion of the WASM package runs them all at once. A lock that holds is kept without asking whether its tag is still in the repository: only mars upgrade moves it.

Enums§

ChooseError
Why no ref could be chosen.
Chosen
What a package ends at.
Constraint
A dependency entry’s version, read.
ParseError
Version text that is not the kind of version the caller said it was.
SelectError
Why no version could be chosen.
SelectionPolicy
How a chosen version relates to the lock.
SettleError
Constraints that cannot both hold on one ref.

Functions§

allows
Whether version meets every semver range in constraints and is not in excluded. Constraint::Latest allows any version; a Constraint::RefPin must have been settled already, so it is not read here.
choose
The whole decision for one package, from every constraint on it and the tags the repository has: settle first (a pin ends it), then the lock if it is kept, then select among the tags that are versions. A tag that is not one (nightly) is ignored, as the binary ignores it when it lists a repository.
keeps_lock
Whether the lock is kept: policy prefers it (a Constraint::Latest asks for the newest, so beside one PreferLockThenLatest prefers nothing) and the locked version is allowed. It does not ask whether the tag is still in the repository, so the answer needs no tag list and a tag deleted upstream keeps the lock. --frozen is the binary’s own rule and asks allows.
parse_constraint
Parse a dependency entry’s version.
parse_tag
Parse a tag name as a semver version tag: one leading v is dropped, then the rest must be strict semver. v1.0.0 and 1.0.0 are versions; latest and nightly-2024 are not.
parse_version
Parse strict semver (no leading v).
require_tag
parse_tag, where a tag that is not a version is the caller’s mistake.
satisfies
Whether version meets a dependency version. A Constraint::RefPin names no version, so nothing meets it.
satisfies_requirement
Whether version meets a package’s requires-mars / requires-meridian (a bare 0.20 means >=0.20.0). An error is a requirement that is not one.
select
Choose one of available that allows and return its index. The newest allowed wins whatever the order of available; of equal versions the later one does. A locked that is among available and that keeps_lock wins instead. Ok(None) is a repository with no version tags: the caller takes its default branch.
settle
Settle every (requester, constraint) on a package: each must hold on the ref it ends at, whether or not it selects anything. A Constraint::RefPin holds only at that ref, a Constraint::Semver never at a pin, and Constraint::Latest anywhere. So the package ends at the one pin if there is one (returned; None means select chooses among the tags), and two pins, or a pin beside a range, refuse. A Latest beside a pin holds but drifts: it asked for the newest and gets a fixed ref.