pub(crate) fn check_argument_for_valid_config_file_name(
user_selected_config_file_name: &str,
) -> Result<String, ConfigFileDefinitionError>Expand description
Checks if the provided string is a valid path to a .toml configuration file.
This function validates a user-selected configuration file path by ensuring that:
- The path exists on the file system.
- It points to a regular file (not a directory).
- The file has an extension.
- The file’s extension is
.toml.
§Arguments
user_selected_config_file_name- A string slice representing the potential path to the configuration file.
§Returns
A Result containing the validated and owned file path as a String on success.
§Errors
Returns a ConfigFileDefinitionError if any validation check fails:
ConfigFileDefinitionError::PathDoesNotExist: If no file or directory exists at the given path.ConfigFileDefinitionError::IsNotAFile: If the path points to a directory, not a regular file.ConfigFileDefinitionError::FileNameHasNoSuffix: If the path does not have a file extension.ConfigFileDefinitionError::SuffixIsNotToml: If the file’s extension is not.toml.