pub fn parse_serialization_path(
path: PathBuf,
extension: &str,
default_file_name_prefix: &str,
) -> Result<PathBuf, ReadWriteError>Expand description
Parse path as one that points to a file that will be used for
serialization.
path can be either of the following:
- Existing directory: in this case a default file name is appended to
path. - Non-existing directory: in this case all dirs in the path are created, and a default file name is appended.
- File in existing dir: in this case the extension is checked to be
expected_extension, thenpathis returned. - File in non-existing dir: dirs in the path are created and the file extension is checked.
The default file name is `default_file_name_prefix + “_” +
- extension`.
Example:
use dapol::read_write_utils::parse_serialization_path;
use std::path::PathBuf;
let extension = "test";
let default_file_name_prefix = "file_prefix";
let dir = PathBuf::from("./");
let path = parse_serialization_path(dir, extension, default_file_name_prefix).unwrap();