arch_toolkit/types/package.rs
1//! Package-related data types for AUR operations.
2
3use serde::{Deserialize, Serialize};
4
5/// Basic AUR package information from search results.
6///
7/// This is a lightweight representation suitable for lists and search results.
8/// For full package details, see [`AurPackageDetails`].
9#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
10pub struct AurPackage {
11 /// Canonical package name.
12 pub name: String,
13 /// Version string as reported by AUR.
14 pub version: String,
15 /// One-line description suitable for list display.
16 pub description: String,
17 /// AUR popularity score when available.
18 #[serde(default, skip_serializing_if = "Option::is_none")]
19 pub popularity: Option<f64>,
20 /// Timestamp when package was flagged out-of-date (Unix timestamp in seconds).
21 #[serde(default, skip_serializing_if = "Option::is_none")]
22 pub out_of_date: Option<u64>,
23 /// Whether package is orphaned (no active maintainer).
24 #[serde(default)]
25 pub orphaned: bool,
26 /// Package maintainer username (None if orphaned).
27 #[serde(default, skip_serializing_if = "Option::is_none")]
28 pub maintainer: Option<String>,
29}
30
31/// Full AUR package details from the info endpoint.
32///
33/// Contains comprehensive information about a package, including all dependencies,
34/// metadata, and AUR-specific fields.
35#[derive(Clone, Debug, Default, Serialize, Deserialize)]
36pub struct AurPackageDetails {
37 /// Package name.
38 pub name: String,
39 /// Full version string.
40 pub version: String,
41 /// Long description.
42 pub description: String,
43 /// Upstream project URL (may be empty if unknown).
44 pub url: String,
45 /// SPDX or human-readable license identifiers.
46 pub licenses: Vec<String>,
47 /// Group memberships.
48 pub groups: Vec<String>,
49 /// Virtual provisions supplied by this package.
50 pub provides: Vec<String>,
51 /// Required dependencies.
52 pub depends: Vec<String>,
53 /// Build dependencies.
54 pub make_depends: Vec<String>,
55 /// Optional dependencies with annotations.
56 pub opt_depends: Vec<String>,
57 /// Conflicting packages.
58 pub conflicts: Vec<String>,
59 /// Packages that this package replaces.
60 pub replaces: Vec<String>,
61 /// Package maintainer username (None if orphaned).
62 #[serde(default, skip_serializing_if = "Option::is_none")]
63 pub maintainer: Option<String>,
64 /// First submission timestamp (Unix timestamp in seconds).
65 #[serde(default, skip_serializing_if = "Option::is_none")]
66 pub first_submitted: Option<i64>,
67 /// Last modification timestamp (Unix timestamp in seconds).
68 #[serde(default, skip_serializing_if = "Option::is_none")]
69 pub last_modified: Option<i64>,
70 /// AUR popularity score when available.
71 #[serde(default, skip_serializing_if = "Option::is_none")]
72 pub popularity: Option<f64>,
73 /// Number of votes on AUR.
74 #[serde(default, skip_serializing_if = "Option::is_none")]
75 pub num_votes: Option<u64>,
76 /// Timestamp when package was flagged out-of-date (Unix timestamp in seconds).
77 #[serde(default, skip_serializing_if = "Option::is_none")]
78 pub out_of_date: Option<u64>,
79 /// Whether package is orphaned (no active maintainer).
80 #[serde(default)]
81 pub orphaned: bool,
82}
83
84/// AUR comment from a package page.
85///
86/// Contains author, date, and content of a comment, with optional timestamp
87/// for reliable chronological sorting.
88#[derive(Clone, Debug, Serialize, Deserialize)]
89pub struct AurComment {
90 /// Stable comment identifier parsed from DOM when available.
91 #[serde(default, skip_serializing_if = "Option::is_none")]
92 pub id: Option<String>,
93 /// Comment author username.
94 pub author: String,
95 /// Human-readable date string.
96 pub date: String,
97 /// Unix timestamp for sorting (None if parsing failed).
98 #[serde(default, skip_serializing_if = "Option::is_none")]
99 pub date_timestamp: Option<i64>,
100 /// URL from the date link (None if not available).
101 #[serde(default, skip_serializing_if = "Option::is_none")]
102 pub date_url: Option<String>,
103 /// Comment content text (formatted as markdown-like syntax).
104 pub content: String,
105 /// Whether this comment is pinned (shown at the top).
106 #[serde(default)]
107 pub pinned: bool,
108}