Skip to content

Commit 0adaf46

Browse files
committed
Update disk image builder to use the builder pattern (Return &mut self)
1 parent 9731b68 commit 0adaf46

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,27 @@ impl<'a> DiskImageBuilder<'a> {
4545
Self { files: Vec::new() }
4646
}
4747
/// Add or replace a ramdisk to be included in the final image.
48-
pub fn set_ramdisk(&mut self, path: &'a PathBuf) {
49-
self.add_or_replace_file(path, RAMDISK_FILE_NAME);
48+
pub fn set_ramdisk(&mut self, path: &'a PathBuf) -> &mut Self {
49+
self.add_or_replace_file(path, RAMDISK_FILE_NAME)
5050
}
5151

5252
/// Add or replace a kernel to be included in the final image.
53-
pub fn set_kernel(&mut self, path: &'a PathBuf) {
53+
pub fn set_kernel(&mut self, path: &'a PathBuf) -> &mut Self {
5454
self.add_or_replace_file(path, KERNEL_FILE_NAME)
5555
}
5656

5757
/// Add or replace arbitrary files.
5858
/// NOTE: You can overwrite internal files if you choose, such as EFI/BOOT/BOOTX64.EFI
5959
/// This can be useful in situations where you want to generate an image, but not use the provided bootloader.
60-
pub fn add_or_replace_file(&mut self, path: &'a PathBuf, target: &'a str) {
60+
pub fn add_or_replace_file(&mut self, path: &'a PathBuf, target: &'a str) -> &mut Self {
6161
self.files.insert(
6262
0,
6363
DiskImageFile::<'a> {
6464
source: &path,
6565
destination: &target,
6666
},
6767
);
68+
self
6869
}
6970
fn create_fat_filesystem_image(
7071
&self,

0 commit comments

Comments
 (0)