rust: Use AsRef<Path> and PathBuf in libraries

Use `AsRef<Path>` instead of `&Path`, &str, .... to be more versatile
and accept more input types. In addition, use `PathBuf` and `Path` for
paths instead of `String` and `str`.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2024-05-23 16:32:57 +00:00
committed by Steffen Eiden
parent 87d43c7a32
commit 4a76efe6d5
13 changed files with 88 additions and 84 deletions

View File

@@ -2,6 +2,8 @@
//
// Copyright IBM Corp. 2023, 2024
use std::path::PathBuf;
/// Result type for this crate
pub type Result<T, E = Error> = std::result::Result<T, E>;
@@ -24,13 +26,13 @@ pub enum Error {
FileIo {
ty: FileIoErrorType,
ctx: String,
path: String,
path: PathBuf,
source: std::io::Error,
},
#[error("Cannot {ty} `{path}`")]
FileAccess {
ty: FileAccessErrorType,
path: String,
path: PathBuf,
source: std::io::Error,
},