[−][src]Trait os_str_bytes::OsStrBytes
A platform agnostic variant of OsStrExt
.
For more information, see the module-level documentation.
Required methods
fn from_bytes<TString: ?Sized>(
string: &TString
) -> Result<Cow<'_, Self>, EncodingError> where
TString: AsRef<[u8]>,
string: &TString
) -> Result<Cow<'_, Self>, EncodingError> where
TString: AsRef<[u8]>,
Converts a byte slice into an equivalent platform-native string.
Errors
See documentation for EncodingError
.
Examples
use std::env; use std::ffi::OsStr; use os_str_bytes::OsStrBytes; let os_string = env::current_exe()?; let os_bytes = os_string.to_bytes(); assert_eq!(os_string, OsStr::from_bytes(&os_bytes).unwrap());
#[must_use]fn to_bytes(&self) -> Cow<'_, [u8]>
Converts a platform-native string into an equivalent byte slice.
Examples
use std::env; use os_str_bytes::OsStrBytes; let os_string = env::current_exe()?; println!("{:?}", os_string.to_bytes());
Implementations on Foreign Types
impl OsStrBytes for OsStr
[src]
fn from_bytes<TString: ?Sized>(
string: &TString
) -> Result<Cow<'_, Self>, EncodingError> where
TString: AsRef<[u8]>,
[src]
string: &TString
) -> Result<Cow<'_, Self>, EncodingError> where
TString: AsRef<[u8]>,
fn to_bytes(&self) -> Cow<'_, [u8]>
[src]
impl OsStrBytes for Path
[src]
fn from_bytes<TString: ?Sized>(
string: &TString
) -> Result<Cow<'_, Self>, EncodingError> where
TString: AsRef<[u8]>,
[src]
string: &TString
) -> Result<Cow<'_, Self>, EncodingError> where
TString: AsRef<[u8]>,