modde_sources/manual/
mod.rs1use std::path::Path;
5
6use modde_core::manifest::wabbajack::DownloadDirective;
7
8use crate::error::{SourceError, SourceResult};
9use crate::traits::{DownloadHandle, DownloadSource, ProgressCallback, VerifiedFile};
10
11pub struct ManualSource;
16
17impl ManualSource {
18 #[must_use]
20 pub fn new() -> Self {
21 Self
22 }
23}
24
25impl Default for ManualSource {
26 fn default() -> Self {
27 Self::new()
28 }
29}
30
31impl DownloadSource for ManualSource {
32 fn can_handle(&self, directive: &DownloadDirective) -> bool {
33 matches!(directive, DownloadDirective::Manual { .. })
34 }
35
36 async fn resolve(&self, directive: &DownloadDirective) -> SourceResult<DownloadHandle> {
37 let DownloadDirective::Manual {
38 url,
39 prompt,
40 expected_name,
41 ..
42 } = directive
43 else {
44 return Err(SourceError::other(anyhow::anyhow!(
45 "not a Manual directive"
46 )));
47 };
48
49 let prompt = if prompt.is_empty() { "(none)" } else { prompt };
50 Err(SourceError::other(anyhow::anyhow!(
51 "manual download required for {expected_name}: visit {url} and place the downloaded \
52 file in the modde downloads directory. Prompt from list author: {prompt}"
53 )))
54 }
55
56 async fn download_with_progress(
57 &self,
58 _handle: DownloadHandle,
59 _dest: &Path,
60 _progress: ProgressCallback,
61 ) -> SourceResult<VerifiedFile> {
62 Err(SourceError::other(anyhow::anyhow!(
63 "manual downloads cannot be fetched automatically"
64 )))
65 }
66}