From afe649e0efc31fcd33a828e54bd6313cd37f1784 Mon Sep 17 00:00:00 2001 From: pablu Date: Tue, 19 May 2026 20:51:10 +0200 Subject: Add available package loading, update README.md, use eyre_color::Result --- src/gentoo/package.rs | 92 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 33 deletions(-) (limited to 'src/gentoo/package.rs') 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, - pub version: String, - pub repository: String, +} + +impl PackageKey { + pub fn from_atom(s: &str) -> Option { + 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, pub description: Option, - pub homepage: Option>, + pub homepage: Vec, pub license: Option, + pub repository: String, +} + +#[derive(Debug, Clone)] +#[allow(dead_code)] +pub struct InstalledPackage { + pub atom: PackageKey, + + pub version: String, + + pub build_time: DateTime, + + pub slot: i32, + + pub metadata: Metadata, + + pub enabled_use_flags: HashSet, + pub iuse: Vec, + pub size: usize, } -// #[allow(dead_code)] -// impl Package { -// pub fn new( -// name: String, -// version: String, -// repository: String, -// size: usize, -// homepage: Option>, -// license: Option, -// description: Option, -// maintainer: Option, -// use_flags: HashSet, -// ) -> Self { -// Package { -// name, -// use_flags, -// version, -// repository, -// maintainer, -// description, -// homepage, -// license, -// size, -// } -// } -// } +#[derive(Debug)] +pub struct Package { + pub atom: PackageKey, + + pub versions: Vec, +} + +#[derive(Debug, Clone)] +pub struct Version { + pub version: String, + + pub metadata: Metadata, + + pub keywords: Vec, + pub iuse: Vec, +} -- cgit 1.3.1