Skip to content

Commit 42b5895

Browse files
committed
Refactor set methods to take destination first
1 parent d4e9a5f commit 42b5895

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,23 @@ impl DiskImageBuilder {
7070

7171
/// Add or replace a kernel to be included in the final image.
7272
pub fn set_kernel(&mut self, path: &Path) -> &mut Self {
73-
self.set_file_source(FileDataSource::File(path.to_path_buf()), KERNEL_FILE_NAME)
73+
self.set_file_source(KERNEL_FILE_NAME, FileDataSource::File(path.to_path_buf()))
7474
}
7575

7676
/// Add or replace a ramdisk to be included in the final image.
7777
pub fn set_ramdisk(&mut self, path: &Path) -> &mut Self {
78-
self.set_file_source(FileDataSource::File(path.to_path_buf()), RAMDISK_FILE_NAME)
78+
self.set_file_source(RAMDISK_FILE_NAME, FileDataSource::File(path.to_path_buf()))
7979
}
8080

8181
/// Configures the runtime behavior of the bootloader.
8282
pub fn set_boot_config(&mut self, boot_config: &BootConfig) -> &mut Self {
8383
let json =
8484
serde_json::to_string_pretty(boot_config).expect("failed to serialize BootConfig");
8585
let bytes = json.as_bytes();
86-
self.set_file_source(FileDataSource::Data(bytes.to_vec()), CONFIG_FILE_NAME)
86+
self.set_file_source(CONFIG_FILE_NAME, FileDataSource::Data(bytes.to_vec()))
8787
}
8888

89-
pub fn set_file_source(&mut self, source: FileDataSource, destination: &str) -> &mut Self {
89+
pub fn set_file_source(&mut self, destination: &str, source: FileDataSource) -> &mut Self {
9090
let destination = destination.to_string();
9191
self.files.insert(
9292
0,
@@ -98,12 +98,12 @@ impl DiskImageBuilder {
9898
self
9999
}
100100

101-
pub fn set_file_contents(&mut self, data: &[u8], destination: &str) -> &mut Self {
102-
self.set_file_source(FileDataSource::Data(data.to_vec()), destination)
101+
pub fn set_file_contents(&mut self, destination: &str, data: &[u8]) -> &mut Self {
102+
self.set_file_source(destination, FileDataSource::Data(data.to_vec()))
103103
}
104104

105-
pub fn set_file(&mut self, file_path: &Path, destination: &str) -> &mut Self {
106-
self.set_file_source(FileDataSource::File(file_path.to_path_buf()), destination)
105+
pub fn set_file(&mut self, destination: &str, file_path: &Path) -> &mut Self {
106+
self.set_file_source(destination, FileDataSource::File(file_path.to_path_buf()))
107107
}
108108

109109
fn create_fat_filesystem_image(

0 commit comments

Comments
 (0)