Skip to main content

compmd_pack/
invalid.rs

1//! Why a text isn't one of the names this crate knows.
2
3/// What is wrong with a text read as a pack's name, a release, a path, a place or an integrity.
4#[derive(Clone, Debug, thiserror::Error, PartialEq, Eq)]
5pub enum Invalid {
6    /// It isn't a pack's name.
7    #[error(
8        "`{0}` isn't a pack's name: `@scope/name`, each part lowercase letters, digits, `-`, `.`, `_` and `~`, not starting with `.` or `_`"
9    )]
10    Name(String),
11    /// It isn't a release: a pack's name, `@` and a version.
12    #[error("`{0}` isn't a release: a pack's name, `@` and a version (`@kit/mermaid@1.2.0`)")]
13    Release(String),
14    /// It isn't a file's path in a pack.
15    #[error(
16        "`{0}` isn't a file's path in a pack: `/`-separated names, none of them empty, `.` or `..`, with no `\\` or `:`"
17    )]
18    Path(String),
19    /// It isn't an integrity.
20    #[error("`{0}` isn't an integrity: `sha256-`, `sha384-` or `sha512-` and a digest, in base64")]
21    Integrity(String),
22}