@@ -84,7 +84,13 @@ impl DiskImageBuilder {
84
84
let bytes = json. as_bytes ( ) ;
85
85
self . set_file_source ( CONFIG_FILE_NAME , FileDataSource :: Data ( bytes. to_vec ( ) ) )
86
86
}
87
-
87
+
88
+ /// Add a file source to the disk image
89
+ /// Example:
90
+ /// ```
91
+ /// image_builder.set_file_source("/extra/README.md", FileDataSource::File(file_path.to_path_buf()))
92
+ /// .set_file_source("/config/config.json", FileDataSource::Data(serialzed_configuration.to_vec()));
93
+ /// ```
88
94
pub fn set_file_source ( & mut self , destination : & str , source : FileDataSource ) -> & mut Self {
89
95
let destination = destination. to_string ( ) ;
90
96
self . files . insert (
@@ -97,10 +103,20 @@ impl DiskImageBuilder {
97
103
self
98
104
}
99
105
106
+ /// Add a file with the specified bytes to the disk image
107
+ /// NOTE: This is just a convenience wrapper around set_file_source
108
+ /// ```
109
+ /// image_builder.set_file_source(destination, FileDataSource::Data(data.to_vec()))
110
+ /// ```
100
111
pub fn set_file_contents ( & mut self , destination : & str , data : & [ u8 ] ) -> & mut Self {
101
112
self . set_file_source ( destination, FileDataSource :: Data ( data. to_vec ( ) ) )
102
113
}
103
114
115
+ /// Add a file with the specified source file to the disk image
116
+ /// NOTE: This is just a convenience wrapper around set_file_source
117
+ /// ```
118
+ /// image_builder.set_file_source(destination, FileDataSource::File(file_path.to_path_buf()))
119
+ /// ```
104
120
pub fn set_file ( & mut self , destination : & str , file_path : & Path ) -> & mut Self {
105
121
self . set_file_source ( destination, FileDataSource :: File ( file_path. to_path_buf ( ) ) )
106
122
}
0 commit comments