Trait os_str_bytes::OsStringBytes
source · [−]pub trait OsStringBytes: Sealed + Sized {
fn from_raw_vec(string: Vec<u8>) -> Result<Self, EncodingError>;
fn into_raw_vec(self) -> Vec<u8>;
}
Expand description
A platform agnostic variant of OsStringExt
.
For more information, see the module-level documentation.
Required methods
fn from_raw_vec(string: Vec<u8>) -> Result<Self, EncodingError>
fn from_raw_vec(string: Vec<u8>) -> Result<Self, EncodingError>
Converts a byte vector into an equivalent platform-native string.
Errors
See documentation for EncodingError
.
Examples
use std::env;
use std::ffi::OsString;
use os_str_bytes::OsStringBytes;
let os_string = env::current_exe()?;
let os_bytes = os_string.clone().into_raw_vec();
assert_eq!(os_string, OsString::from_raw_vec(os_bytes).unwrap());
fn into_raw_vec(self) -> Vec<u8>
fn into_raw_vec(self) -> Vec<u8>
Converts a platform-native string into an equivalent byte vector.
Examples
use std::env;
use os_str_bytes::OsStringBytes;
let os_string = env::current_exe()?;
println!("{:?}", os_string.into_raw_vec());