A Rust library for parsing and validating Vers-like Specifiers (vls) as defined in CSAF 2.0 and CSAF 2.1.
vls is the <constraints> portion of a vers URL without the vers:<type>/ prefix.
It represents a |-separated list of constraints each consisting of an implicit or explicit comparator and a version string.
Due to the undefined / unknown schema, it is nearly impossible for tools to reliably determine whether a given version is in the range or not. vls is a fallback option and SHOULD NOT be used unless really necessary.
1.88.0
Add vls to your Cargo.toml:
[dependencies]
vls = "0.1"Note: This crate has not yet been published to crates.io. In the meantime, use a git dependency:
[dependencies]
vls = { git = "https://github.com/csaf-rs/vls" }use vls::{Vls, Comparator};
let vls: Vls = ">=1.0.0|<2.0.0".parse().unwrap();
assert_eq!(vls.constraints().len(), 2);
assert_eq!(vls.to_string(), ">=1.0.0|<2.0.0");
let constraints = vls.constraints();
assert_eq!(constraints[0].comparator(), &Comparator::GreaterThanOrEqual);
assert_eq!(constraints[0].version().to_string(), "1.0.0");
assert_eq!(constraints[1].comparator(), &Comparator::LessThan);
assert_eq!(constraints[1].version().to_string(), "2.0.0");Licensed under the Apache License, Version 2.0.