isr_dl_linux/ubuntu/request.rs
1//! Request and response types for `UbuntuSymbolDownloader`.
2
3use std::path::PathBuf;
4
5use bon::Builder;
6
7use crate::UbuntuVersionSignature;
8
9/// A request for one or more kernel artifacts.
10#[derive(Builder, Debug)]
11pub struct UbuntuSymbolRequest {
12 /// Version signature identifying the kernel to fetch.
13 pub version_signature: UbuntuVersionSignature,
14
15 /// Policy for the kernel image. `None` means do not download.
16 pub linux_image: Option<ArtifactPolicy>,
17
18 /// Policy for the kernel debug-symbols image.
19 pub linux_image_dbgsym: Option<ArtifactPolicy>,
20
21 /// Policy for the kernel modules package (which contains `System.map`).
22 pub linux_modules: Option<ArtifactPolicy>,
23}
24
25/// Per-artifact download and optional extraction policy.
26#[derive(Builder, Debug, Clone)]
27pub struct ArtifactPolicy {
28 /// Filename policy for the downloaded `.deb`.
29 pub deb: FilenamePolicy,
30
31 /// `None` means keep only the .deb (no extraction).
32 pub extract: Option<FilenamePolicy>,
33}
34
35/// How to name a file on disk.
36#[derive(Debug, Clone)]
37pub enum FilenamePolicy {
38 /// Use the canonical filename from the package entry (for debs) or the
39 /// basename of the path inside the deb (for extracts).
40 Original,
41 /// Use a caller-supplied filename.
42 Custom(PathBuf),
43}
44
45impl FilenamePolicy {
46 /// Returns a policy for using the original filename.
47 pub fn original() -> Self {
48 Self::Original
49 }
50
51 /// Returns a policy for using a custom filename.
52 pub fn custom(path: impl Into<PathBuf>) -> Self {
53 Self::Custom(path.into())
54 }
55}
56
57/// Result of a `download()` call. Mirrors the request structurally: if the
58/// request had `Some(policy)` for an artifact, the response has `Some(paths)`.
59#[derive(Debug, Default, Clone)]
60pub struct UbuntuSymbolPaths {
61 /// Directory that holds the per-signature subdirectory.
62 pub output_directory: PathBuf,
63
64 /// Paths of the kernel image, if requested.
65 pub linux_image: Option<ArtifactPaths>,
66
67 /// Paths of the kernel debug-symbols image, if requested.
68 pub linux_image_dbgsym: Option<ArtifactPaths>,
69
70 /// Paths of the kernel modules package, if requested.
71 pub linux_modules: Option<ArtifactPaths>,
72}
73
74/// Per-artifact resulting paths.
75#[derive(Debug, Clone)]
76pub struct ArtifactPaths {
77 /// Path to the downloaded `.deb`.
78 pub deb: PathBuf,
79
80 /// Populated iff the request's `extract` was `Some`.
81 pub extracted: Option<PathBuf>,
82}