pub trait PathUtf8Encoder {
// Required method
fn to_utf8_string(&self) -> String;
}Expand description
Extension trait for encoding paths to UTF-8 strings.
This is a separate trait from Utf8Encoder due to Rust’s coherence rules
preventing blanket implementations from coexisting with specific type implementations.
Required Methods§
Sourcefn to_utf8_string(&self) -> String
fn to_utf8_string(&self) -> String
Converts a path to a UTF-8 string, replacing invalid bytes with fallback characters.
§Example
use ps_str::PathUtf8Encoder;
use std::path::Path;
let path = Path::new("hello.txt");
let encoded = path.to_utf8_string();
assert_eq!(encoded, "hello.txt");