diff options
| author | pablu <me@pablu.de> | 2026-05-19 20:51:10 +0200 |
|---|---|---|
| committer | pablu <me@pablu.de> | 2026-05-19 20:51:10 +0200 |
| commit | afe649e0efc31fcd33a828e54bd6313cd37f1784 (patch) | |
| tree | c2cec9450cc1778f62c6339dad9c8f7d43c46b16 /src/gentoo/package.rs | |
| parent | a6b4b29aaa222fa5c2f30cad233e97cb8125f96f (diff) | |
Add available package loading, update README.md, use eyre_color::Result
Diffstat (limited to 'src/gentoo/package.rs')
| -rw-r--r-- | src/gentoo/package.rs | 92 |
1 files changed, 59 insertions, 33 deletions
diff --git a/src/gentoo/package.rs b/src/gentoo/package.rs index a74a09c..d1596f7 100644 --- a/src/gentoo/package.rs +++ b/src/gentoo/package.rs @@ -1,44 +1,70 @@ use std::collections::HashSet; +use chrono::{DateTime, Utc}; + use crate::gentoo::UseFlag; -#[derive(Debug, Clone)] -#[allow(dead_code)] -pub struct Package { +#[derive(Debug, Clone, Hash, Eq, PartialEq)] +pub struct PackageKey { + pub category: String, pub name: String, - pub use_flags: HashSet<UseFlag>, - pub version: String, - pub repository: String, +} + +impl PackageKey { + pub fn from_atom(s: &str) -> Option<Self> { + let (category, name) = s.split_once('/')?; + Some(Self { + category: category.to_string(), + name: name.to_string(), + }) + } + + pub fn qualified_name(&self) -> String { + format!("{}/{}", self.category, self.name) + } +} + +#[derive(Debug, Clone)] +pub struct Metadata { pub maintainer: Option<String>, pub description: Option<String>, - pub homepage: Option<Vec<String>>, + pub homepage: Vec<String>, pub license: Option<String>, + pub repository: String, +} + +#[derive(Debug, Clone)] +#[allow(dead_code)] +pub struct InstalledPackage { + pub atom: PackageKey, + + pub version: String, + + pub build_time: DateTime<Utc>, + + pub slot: i32, + + pub metadata: Metadata, + + pub enabled_use_flags: HashSet<String>, + pub iuse: Vec<UseFlag>, + pub size: usize, } -// #[allow(dead_code)] -// impl Package { -// pub fn new( -// name: String, -// version: String, -// repository: String, -// size: usize, -// homepage: Option<Vec<String>>, -// license: Option<String>, -// description: Option<String>, -// maintainer: Option<String>, -// use_flags: HashSet<UseFlag>, -// ) -> Self { -// Package { -// name, -// use_flags, -// version, -// repository, -// maintainer, -// description, -// homepage, -// license, -// size, -// } -// } -// } +#[derive(Debug)] +pub struct Package { + pub atom: PackageKey, + + pub versions: Vec<Version>, +} + +#[derive(Debug, Clone)] +pub struct Version { + pub version: String, + + pub metadata: Metadata, + + pub keywords: Vec<String>, + pub iuse: Vec<UseFlag>, +} |
