Trait os_str_bytes::OsStringBytes[][src]

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

Converts a byte vector into an equivalent platform-native string.

Provided byte strings should always be valid for the unspecified encoding used by this crate.

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());

Converts a platform-native string into an equivalent byte vector.

The returned byte string will use an unspecified encoding.

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

Implementors