cpclib_runner/runner/
extra.rs1use std::{fmt::Debug, hash::Hash};
4
5use bon::Builder;
6
7use crate::delegated::{
8 DownloadableInformation, ExecutableInformation, InternetStaticCompiledApplication,
9 StaticInformation
10};
11
12#[derive(Clone, Debug, PartialEq, Eq, Hash, Builder)]
14pub struct ExtraTool<BaseTool>
15where BaseTool: Clone + Debug + PartialEq + Eq + Hash
16{
17 tool: BaseTool,
18 target_os_exec_fname: Option<&'static str>,
19 target_os_folder: Option<&'static str>
20}
21
22impl<BaseTool> ExtraTool<BaseTool>
23where BaseTool: Clone + Debug + PartialEq + Eq + Hash + Default
24{
25 pub fn owner(&self) -> &BaseTool {
26 &self.tool
27 }
28}
29impl<BaseTool: StaticInformation> StaticInformation for ExtraTool<BaseTool>
39where BaseTool: Clone + Debug + PartialEq + Eq + Hash
40{
41 fn static_download_urls(&self) -> &'static crate::delegated::MutiplatformUrls {
42 self.tool.static_download_urls()
43 }
44
45 fn target_os_url(&self) -> Option<&'static str> {
46 self.tool.target_os_url()
47 }
48
49 fn target_os_url_generator(&self) -> crate::delegated::UrlGenerator {
50 self.tool.target_os_url_generator()
51 }
52}
53
54impl<BaseTool: DownloadableInformation> DownloadableInformation for ExtraTool<BaseTool>
55where BaseTool: Clone + Debug + PartialEq + Eq + Hash
56{
57 fn target_os_archive_format(&self) -> crate::delegated::ArchiveFormat {
58 self.tool.target_os_archive_format()
59 }
60
61 fn target_os_postinstall<E: cpclib_common::event::EventObserver>(
62 &self
63 ) -> Option<crate::delegated::PostInstall<E>>
64 where BaseTool: Clone + Debug + PartialEq + Eq + Hash {
65 self.tool.target_os_postinstall()
66 }
67}
68
69impl<BaseTool: ExecutableInformation> ExecutableInformation for ExtraTool<BaseTool>
70where BaseTool: Clone + Debug + PartialEq + Eq + Hash
71{
72 fn target_os_exec_fname(&self) -> &'static str {
73 if let Some(fname) = &self.target_os_exec_fname {
74 fname
75 }
76 else {
77 self.tool.target_os_exec_fname()
78 }
79 }
80
81 fn target_os_folder(&self) -> &'static str {
82 if let Some(folder) = &self.target_os_folder {
83 folder
84 }
85 else {
86 self.tool.target_os_folder()
87 }
88 }
89
90 fn target_os_run_in_dir(&self) -> super::runner::RunInDir {
91 self.tool.target_os_run_in_dir()
92 }
93}
94
95impl<BaseTool: InternetStaticCompiledApplication> InternetStaticCompiledApplication
96 for ExtraTool<BaseTool>
97where BaseTool: Clone + Debug + PartialEq + Eq + Hash
98{
99}