/// Writes all observed `Record`s to the specified file.
/// Fails if the file or its parent directory cannot be created.
///
/// # Parameters
///
/// * `path` - the path to the output file
Writes all observed `Record`s to the specified file.
Fails if the file or its parent directory cannot be created.
Writes all observed ` Record ` s to the specified file . Fails if the file or its parent directory cannot be created .
pub fn write_records_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), PvError> {
        // Make sure there is a last path component that can be written to.
        let parent_directory = path
            .as_ref()
            .parent()
            .ok_or(PvError::InternalError(format!(
                "{:?} does not point to a file.",
                path.as_ref()
            )))?;
        // Create parent directories.
        create_dir_all(parent_directory)?;
        // Default writing options are fine for file creation.
        let writer = File::create(path)?;
        serde_json::to_writer(writer, &self.records)?;
        Ok(())
    }
pub fn write_records_to_file < P : AsRef < Path > > ( & self , path : P ) -> Result < ( ) , PvError > { // Make sure there is a last path component that can be written to. let parent_directory = path . as_ref ( ) . parent ( ) . ok_or ( PvError :: InternalError ( format ! ( " " path as_ref ( ) ) ) ) ? ; // Create parent directories. create_dir_all ( parent_directory ) ? ; // Default writing options are fine for file creation. let writer = File :: create ( path ) ? ; serde_json :: to_writer ( writer , & self . records ) ? ; Ok ( ( ) ) }
Writes all observed `Record`s to the specified file.
Writes all observed ` Record ` s to the specified file .
&self
path
P