-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathbootloader.rs
More file actions
57 lines (54 loc) · 2.02 KB
/
bootloader.rs
File metadata and controls
57 lines (54 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) [2025] SUSE LLC
//
// All Rights Reserved.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, contact SUSE LLC.
//
// To contact SUSE LLC about this file by physical or electronic mail, you may
// find current contact information at www.suse.com.
//! Implements a data model for Bootloader configuration.
use merge::Merge;
use serde::{Deserialize, Serialize};
/// Bootloader configuration.
#[derive(Clone, Debug, Serialize, Deserialize, Default, Merge, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
#[merge(strategy = merge::option::overwrite_none)]
#[schema(as = bootloader::Config)]
pub struct Config {
/// Whether bootloader should stop on boot menu.
#[serde(skip_serializing_if = "Option::is_none")]
pub stop_on_boot_menu: Option<bool>,
/// Bootloader timeout.
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<u32>,
/// Bootloader extra kernel parameters.
#[serde(skip_serializing_if = "Option::is_none")]
pub extra_kernel_params: Option<String>,
/// Whether bootloader should update persistent RAM.
#[serde(skip_serializing_if = "Option::is_none")]
pub update_nvram: Option<bool>,
}
impl Config {
pub fn to_option(self) -> Option<Self> {
if self.stop_on_boot_menu.is_none()
&& self.timeout.is_none()
&& self.extra_kernel_params.is_none()
&& self.update_nvram.is_none()
{
None
} else {
Some(self)
}
}
}