Crates.io | cve-id |
lib.rs | cve-id |
version | 0.2.0 |
created_at | 2025-08-12 14:19:37.744067+00 |
updated_at | 2025-08-21 16:56:33.735248+00 |
description | Typesafe Common Vulnerabilities and Exposures (CVE) Identifier |
homepage | |
repository | https://github.com/robo9k/cveid-rs |
max_upload_size | |
id | 1792066 |
size | 32,983 |
Typesafe Common Vulnerabilities and Exposures (CVE) Identifier
use cve_id::{CveId, CveYear};
fn cveid_example() -> Result<(), Box<dyn std::error::Error>> {
let cve_id = CveId::from_str("CVE-1999-0001")?;
assert_eq!(cve_id.year(), 1999);
assert_eq!(cve_id.number(), 1);
assert_eq!(cve_id.to_string(), "CVE-1999-0001");
const CVE_TEST_YEAR: CveYear = {
let Ok(year) = CveYear::new(1900) else {
panic!("not a valid CVE year")
};
year
};
const CVE_TEST_ID: CveId = CveId::new(CVE_TEST_YEAR, 42);
assert!(CVE_TEST_ID.is_example_or_test());
Ok(())
}