Crates.io | fmri |
lib.rs | fmri |
version | 1.0.3 |
source | src |
created_at | 2023-09-21 10:03:54.830147 |
updated_at | 2024-06-13 14:14:44.981818 |
description | Implementation of IPS package identifier - FMRI |
homepage | |
repository | https://github.com/aueam/fmri |
max_upload_size | |
id | 979265 |
size | 34,368 |
Implementation of IPS package identifier - FMRI. Provides FMRI, Publisher, Version structs and version comparing.
Check out the changelog on GitHub
Documentation is here
This example shows some of the functionality of this library.
use std::cmp::Ordering;
use fmri::{
FMRI,
publisher::Publisher,
version::Version,
};
fn main() {
let raw_fmri = &"pkg://publisher/system/library@0.5.11,5.11-0.175.1.0.0.2.1".to_owned();
// create fmri
let mut fmri = FMRI::parse_raw(raw_fmri).unwrap();
// create new publisher
let publisher = Publisher::new("test".to_owned()).unwrap();
// change publisher of FMRI
fmri.change_publisher(publisher);
// remove version
fmri.remove_version();
assert_eq!(format!("{}", fmri), "pkg://test/system/library");
// get package name from fmri
assert_eq!(fmri.get_package_name_as_string(), "system/library");
// prepare two FMRIs
let fmri_a = FMRI::parse_raw(&"test@1".to_owned()).unwrap();
let fmri_b = FMRI::parse_raw(&"test@2".to_owned()).unwrap();
// compare them (fmri_a is older than fmri_b)
assert_eq!(fmri_a.cmp(&fmri_b), Ordering::Less);
// print version of fmri_b
assert_eq!(fmri_b.get_version(), Some(Version::new("2".to_owned()).unwrap()));
}