pub fn bytes_to_os_string(bytes: Vec<u8>) -> Result<OsString, ConvertBytesError>
Expand description
Convert a byte vec to a platform-specific OsString
.
Unsupported platforms fallback to converting through String
.
§Examples
let bytes = b"/etc/passwd".to_vec();
assert_eq!(bytes_to_os_string(bytes), Ok(OsString::from("/etc/passwd")));
§Errors
On unix-like platforms, this function is infallible.
On Windows, if the given byte slice does not contain valid UTF-8, an error is returned.