Skip to main content

Crate compmd_pack

Crate compmd_pack 

Source
Expand description

compmd-pack: the names CompMD packs and their files are known by (spec §6.4), each checked once, when it is made, so a name that could leave a folder, or isn’t a pack’s, can’t exist.

The processor (compmd, which re-exports this crate as compmd::pack) and every host’s code (compmd-host) use the same types, so a pack’s name, a release and a file’s place mean one thing everywhere.

use compmd_pack::{Integrity, PackName, Place};

let place: Place = "@kit/mermaid@1.2.0/dist/mermaid.js".parse()?;
assert_eq!(place.release.pack, "@kit/mermaid".parse::<PackName>()?);
assert_eq!(place.release.to_string(), "@kit/mermaid@1.2.0");
assert_eq!(place.path.as_str(), "dist/mermaid.js");

let integrity: Integrity = "sha512-9c1fQe0=".parse()?;
assert_eq!(integrity.to_string(), "sha512-9c1fQe0=");

Structs§

FilePath
A file’s path in a pack, dist/mermaid.js.
Integrity
An integrity, sha512-9c1fQe…. In JSON it is that string.
PackName
A pack’s name, @scope/name.
Place
A file of a pack, by its place. In JSON it is {"pack": …, "version": …, "path": …}.
ReleaseId
A pack at one version. In JSON it is {"pack": "@kit/mermaid", "version": "1.2.0"}.

Enums§

Algorithm
A hash’s algorithm.
Invalid
What is wrong with a text read as a pack’s name, a release, a path, a place or an integrity.

Functions§

newest_matching
The newest of versions that range takes, as the processor reads the version or range after a pack’s name in an import’s from (spec §6.1): 1.4.2 is exactly that version, 1 and ^1.4 ranges, * any. None when none matches, or range isn’t one. A host that fetches the packs a document needs picks a version with this, so the processor takes the release it was given.
range
The range text is, and whether it is one exact version: 1.4.2 is exactly that release, unlike Cargo’s requirements, where it would be ^1.4.2. None when it isn’t a range.