Skip to main content

libobs_bootstrapper/
options.rs

1pub const GITHUB_REPO: &str = "libobs-rs/libobs-builds";
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
4pub enum UpdateTargetMode {
5    #[default]
6    LatestCompatibleSameMajor,
7    LatestCompatibleSameMajorMinor,
8}
9
10#[derive(Debug, Clone)]
11pub struct ObsBootstrapperOptions {
12    pub(crate) repository: String,
13    pub(crate) update: bool,
14    pub(crate) restart_after_update: bool,
15    pub(crate) update_target_mode: UpdateTargetMode,
16}
17
18impl ObsBootstrapperOptions {
19    pub fn new() -> Self {
20        ObsBootstrapperOptions {
21            repository: GITHUB_REPO.to_string(),
22            update: true,
23            restart_after_update: true,
24            update_target_mode: UpdateTargetMode::LatestCompatibleSameMajor,
25        }
26    }
27
28    pub fn set_repository(mut self, repository: &str) -> Self {
29        self.repository = repository.to_string();
30        self
31    }
32
33    pub fn get_repository(&self) -> &str {
34        &self.repository
35    }
36
37    /// `true` if the updater should check for updates and download them if available.
38    /// `false` if the updater should not check for updates and only install OBS if required.
39    pub fn set_update(mut self, update: bool) -> Self {
40        self.update = update;
41        self
42    }
43
44    /// Controls which compatible release line is considered when checking for updates.
45    pub fn set_update_target_mode(mut self, update_target_mode: UpdateTargetMode) -> Self {
46        self.update_target_mode = update_target_mode;
47        self
48    }
49
50    /// Disables the automatic restart of the application after the update is applied.
51    pub fn set_no_restart(mut self) -> Self {
52        self.restart_after_update = false;
53        self
54    }
55}
56
57impl Default for ObsBootstrapperOptions {
58    fn default() -> Self {
59        ObsBootstrapperOptions::new()
60    }
61}