Skip to content

Commit 92f6e74

Browse files
committed
feat(lib): add files
Signed-off-by: Kaiyang Wu <[email protected]>
1 parent 8758b9a commit 92f6e74

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

pkgsite-lib/src/lib.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod models;
1111
use error::{PResult, PackagesSiteError};
1212
pub use models::*;
1313
use models::{
14-
depends::Depends, index::Index, info::Info, rdepends::RDepends, search::Search,
14+
depends::Depends, files::Files, index::Index, info::Info, rdepends::RDepends, search::Search,
1515
updates::Updates,
1616
};
1717

@@ -180,6 +180,27 @@ impl PackagesSiteClient {
180180
.json::<Updates>()
181181
.await?)
182182
}
183+
184+
pub async fn files(
185+
&self,
186+
arch: &str,
187+
branch: &str,
188+
package: &str,
189+
version: &str,
190+
) -> PResult<Files> {
191+
Ok(self
192+
.get_data(format!(
193+
"{}/files/{}/{}/{}/{}?type=json",
194+
&self.url,
195+
arch.to_string(),
196+
branch,
197+
package,
198+
version
199+
))
200+
.await?
201+
.json::<Files>()
202+
.await?)
203+
}
183204
}
184205

185206
#[cfg(test)]

pkgsite-lib/src/models/files.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
#[derive(Serialize, Deserialize, Debug)]
4+
pub struct File {
5+
pub filename: Option<String>,
6+
pub size: i64,
7+
pub ftype: i16,
8+
pub perm: i32,
9+
pub uid: i64,
10+
pub gid: i64,
11+
pub uname: String,
12+
pub gname: String,
13+
}
14+
15+
#[derive(Serialize, Deserialize, Debug)]
16+
pub struct Package {
17+
pub package: String,
18+
pub version: String,
19+
pub architecture: String,
20+
pub repo: String,
21+
pub maintainer: String,
22+
pub installed_size: i64,
23+
pub filename: String,
24+
pub size: i64,
25+
pub sha256: String,
26+
}
27+
28+
#[derive(Serialize, Deserialize, Debug)]
29+
pub struct Files {
30+
pub files: Vec<File>,
31+
pub sodepends: Vec<String>,
32+
pub soprovides: Vec<String>,
33+
pub pkg_debtime: i32,
34+
pub pkg: Package,
35+
}

pkgsite-lib/src/models/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod depends;
2+
pub mod files;
23
pub mod index;
34
pub mod info;
45
pub mod rdepends;

0 commit comments

Comments
 (0)