Struct std::ffi::OsStr
[−]
[src]
pub struct OsStr {
// some fields omitted
}Slices into OS strings.
Methods
impl OsStr
fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &OsStr
Coerces into an OsStr slice.
fn to_str(&self) -> Option<&str>
Yields a &str slice if the OsStr is valid unicode.
This conversion may entail doing a check for UTF-8 validity.
fn to_string_lossy(&self) -> Cow<str>
Converts an OsStr to a Cow<str>.
Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
fn to_os_string(&self) -> OsString
Copies the slice into an owned OsString.
fn to_bytes(&self) -> Option<&[u8]>
: RFC was closed, hides subtle Windows semantics
Yields this OsStr as a byte slice.
Platform behavior
On Unix systems, this is a no-op.
On Windows systems, this returns None unless the OsStr is
valid unicode, in which case it produces UTF-8-encoded
data. This may entail checking validity.
fn to_cstring(&self) -> Option<CString>
: RFC was closed, hides subtle Windows semantics
Creates a CString containing this OsStr data.
Fails if the OsStr contains interior nulls.
This is a convenience for creating a CString from
self.to_bytes(), and inherits the platform behavior of the
to_bytes method.