Struct std::ffi::OsString
[−]
[src]
pub struct OsString { // some fields omitted }
Owned, mutable OS strings.
Methods
impl OsString
fn new() -> OsString
Constructs a new empty OsString
`OsString`.
fn from_bytes<B>(bytes: B) -> Option<OsString> where B: Into<Vec<u8>>
: recently added
Constructs an OsString
`OsString` from a byte sequence.
Platform behavior
On Unix systems, any byte sequence can be successfully
converted into an OsString
`OsString`.
On Windows system, only UTF-8 byte sequences will successfully
convert; non UTF-8 data will produce None
`None`.
fn as_os_str(&self) -> &OsStr
Converts to an OsStr
`OsStr` slice.
fn into_string(self) -> Result<String, OsString>
Converts the OsString
`OsStringinto a
` into a String
`String` if it contains valid Unicode data.
On failure, ownership of the original OsString
`OsString` is returned.
fn push<T: AsRef<OsStr>>(&mut self, s: T)
Extends the string with the given &OsStr
`&OsStr` slice.
Methods from Deref<Target=OsStr>
fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &OsStr
Coerces into an OsStr
`OsStr` slice.
fn to_str(&self) -> Option<&str>
Yields a &str
`&strslice if the
` slice if the OsStr
`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
`OsStrto a
` to a Cow<str>
`Cow
Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
fn to_os_string(&self) -> OsString
Copies the slice into an owned OsString
`OsString`.
fn to_bytes(&self) -> Option<&[u8]>
: recently added
Yields this OsStr
`OsStr` as a byte slice.
Platform behavior
On Unix systems, this is a no-op.
On Windows systems, this returns None
`Noneunless the
` unless the OsStr
`OsStr` is
valid unicode, in which case it produces UTF-8-encoded
data. This may entail checking validity.
fn to_cstring(&self) -> Option<CString>
: recently added
Creates a CString
`CStringcontaining this
` containing this OsStr
`OsStr` data.
Fails if the OsStr
`OsStr` contains interior nulls.
This is a convenience for creating a CString
`CStringfrom
` from
self.to_bytes()
`self.to_bytes(), and inherits the platform behavior of the
`, and inherits the platform behavior of the
to_bytes
`to_bytes` method.