Trait os_str_bytes::OsStringBytes [−][src]
pub trait OsStringBytes: Sealed + Sized { fn from_raw_vec(string: Vec<u8>) -> Result<Self, EncodingError>; #[must_use] 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>
[src]
Expand description
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());
#[must_use]fn into_raw_vec(self) -> Vec<u8>
[src]
#[must_use]
fn into_raw_vec(self) -> Vec<u8>Expand description
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());
Implementations on Foreign Types
impl OsStringBytes for OsString
[src]
impl OsStringBytes for OsString
[src]fn from_raw_vec(string: Vec<u8>) -> Result<Self, EncodingError>
[src]
fn into_raw_vec(self) -> Vec<u8>
[src]
impl OsStringBytes for PathBuf
[src]
impl OsStringBytes for PathBuf
[src]