@@ -84,7 +84,13 @@ impl DiskImageBuilder {
8484 let bytes = json. as_bytes ( ) ;
8585 self . set_file_source ( CONFIG_FILE_NAME , FileDataSource :: Data ( bytes. to_vec ( ) ) )
8686 }
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+ /// ```
8894 pub fn set_file_source ( & mut self , destination : & str , source : FileDataSource ) -> & mut Self {
8995 let destination = destination. to_string ( ) ;
9096 self . files . insert (
@@ -97,10 +103,20 @@ impl DiskImageBuilder {
97103 self
98104 }
99105
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+ /// ```
100111 pub fn set_file_contents ( & mut self , destination : & str , data : & [ u8 ] ) -> & mut Self {
101112 self . set_file_source ( destination, FileDataSource :: Data ( data. to_vec ( ) ) )
102113 }
103114
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+ /// ```
104120 pub fn set_file ( & mut self , destination : & str , file_path : & Path ) -> & mut Self {
105121 self . set_file_source ( destination, FileDataSource :: File ( file_path. to_path_buf ( ) ) )
106122 }
0 commit comments