tpm: remove mixture of str and Path

`impl AsRef<Path>` is the most idiomatic way to consume paths
in Rust. I removed the mixture.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-11-26 14:04:47 +01:00
committed by Rob Bradford
parent c53781bf5f
commit afcb2b285f
4 changed files with 14 additions and 8 deletions

View File

@@ -86,10 +86,12 @@ impl Emulator {
///
/// * `path` - A path to the Unix Domain Socket swtpm is listening on
///
pub fn new(path: &str) -> Result<Self> {
if !Path::new(&path).exists() {
pub fn new(path: impl AsRef<Path>) -> Result<Self> {
let path = path.as_ref();
if !path.exists() {
return Err(Error::InitializeEmulator(anyhow!(
"The input TPM Socket path: {path:?} does not exist"
"The input TPM Socket path: {:?} does not exist",
path.to_str().unwrap()
)));
}
let mut socket = SocketDev::new();