lib_remotebuild_rs/
aur.rs1use crate::{
2 jobs::{Type, UploadType},
3 librb, request, request_error, responses,
4};
5
6use std::collections::HashMap;
7
8pub const DM_TOKEN: &str = "DM_Token"; pub const DM_USER: &str = "DM_USER"; pub const DM_HOST: &str = "DM_HOST"; pub const DM_NAMESPACE: &str = "DM_NAMESPACE"; pub const AUR_PACKAGE: &str = "REPO"; pub struct AURBuild<'a> {
16 pub librb: &'a librb::LibRb,
17 pub args: HashMap<String, String>,
18 pub upload_type: UploadType,
19 pub disable_ccache: bool,
20}
21
22impl<'a> AURBuild<'a> {
23 pub fn without_ccache(mut self) -> Self {
25 self.disable_ccache = true;
26 self
27 }
28
29 pub fn with_dmanager(
31 mut self,
32 username: String,
33 token: String,
34 host: String,
35 namespace: String,
36 ) -> Self {
37 self.upload_type = UploadType::DataManager;
38 self.args.insert(DM_TOKEN.to_owned(), token);
39 self.args.insert(DM_USER.to_owned(), username);
40 self.args.insert(DM_HOST.to_owned(), host);
41
42 if !namespace.is_empty() {
43 self.args.insert(DM_NAMESPACE.to_owned(), namespace);
44 }
45
46 self
47 }
48
49 pub async fn create_job(
51 self,
52 ) -> Result<request::RequestResult<responses::AddJob>, request_error::Error> {
53 self.librb
54 .add_job(
55 Type::JobAUR,
56 self.upload_type,
57 self.args,
58 self.disable_ccache,
59 )
60 .await
61 }
62}