parse_serialization_path

Function parse_serialization_path 

Source
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:

  1. Existing directory: in this case a default file name is appended to path.
  2. Non-existing directory: in this case all dirs in the path are created, and a default file name is appended.
  3. File in existing dir: in this case the extension is checked to be expected_extension, then path is returned.
  4. 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();