1- use std:: time:: { Duration , Instant , SystemTime } ;
1+ use std:: {
2+ path:: PathBuf ,
3+ time:: { Duration , Instant , SystemTime } ,
4+ } ;
25
36use bytesize:: ByteSize ;
47use saluki_error:: { ErrorContext as _, GenericError } ;
@@ -19,12 +22,19 @@ pub struct Driver {
1922impl Driver {
2023 /// Creates a new `Driver` based on the given configuration.
2124 ///
25+ /// If `output_file` is provided, the driver will write all payloads to the given file path instead of the
26+ /// configured target. The configured target is still used to determine corpus generation parameters (e.g.
27+ /// framing), so the bytes written to the file are identical to what would be sent over the wire.
28+ ///
2229 /// # Errors
2330 ///
2431 /// If an error occurs while creating the corpus, it will be returned.
25- pub fn new ( config : Config ) -> Result < Self , GenericError > {
32+ pub fn new ( config : Config , output_file : Option < PathBuf > ) -> Result < Self , GenericError > {
2633 let corpus = Corpus :: from_config ( & config) . error_context ( "Failed to generate test corpus." ) ?;
27- let sender = TargetSender :: from_config ( & config) . error_context ( "Failed to create target sender." ) ?;
34+ let sender = match output_file {
35+ Some ( path) => TargetSender :: from_file ( & path) . error_context ( "Failed to create file target sender." ) ?,
36+ None => TargetSender :: from_config ( & config) . error_context ( "Failed to create target sender." ) ?,
37+ } ;
2838
2939 Ok ( Self { config, corpus, sender } )
3040 }
0 commit comments