Struct std::ffi::OsString [] [src]

pub struct OsString {
    // some fields omitted
}
1.0.0

A type that can represent owned, mutable platform-native strings, but is cheaply inter-convertible with Rust strings.

The need for this type arises from the fact that:

OsString and OsStr bridge this gap by simultaneously representing Rust and platform-native string values, and in particular allowing a Rust string to be converted into an "OS" string with no cost.

Methods

impl OsString

fn new() -> OsString

Constructs a new empty OsString.

fn as_os_str(&self) -> &OsStr

Converts to an OsStr slice.

fn into_string(self) -> Result<String, OsString>

Converts the OsString into a String if it contains valid Unicode data.

On failure, ownership of the original OsString is returned.

fn push<T: AsRef<OsStr>>(&mut self, s: T)

Extends the string with the given &OsStr slice.

fn with_capacity(capacity: usize) -> OsString1.9.0

Creates a new OsString with the given capacity.

The string will be able to hold exactly capacity lenth units of other OS strings without reallocating. If capacity is 0, the string will not allocate.

See main OsString documentation information about encoding.

fn clear(&mut self)1.9.0

Truncates the OsString to zero length.

fn capacity(&self) -> usize1.9.0

Returns the capacity this OsString can hold without reallocating.

See OsString introduction for information about encoding.

fn reserve(&mut self, additional: usize)1.9.0

Reserves capacity for at least additional more capacity to be inserted in the given OsString.

The collection may reserve more space to avoid frequent reallocations.

fn reserve_exact(&mut self, additional: usize)1.9.0

Reserves the minimum capacity for exactly additional more capacity to be inserted in the given OsString. Does nothing if the capacity is already sufficient.

Note that the allocator may give the collection more space than it requests. Therefore capacity can not be relied upon to be precisely minimal. Prefer reserve if future insertions are expected.

Methods from Deref<Target=OsStr>

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 is_empty(&self) -> bool1.9.0

Checks whether the OsStr is empty.

fn len(&self) -> usize1.9.0

Returns the length of this OsStr.

Note that this does not return the number of bytes in this string as, for example, OS strings on Windows are encoded as a list of u16 rather than a list of bytes. This number is simply useful for passing to other methods like OsString::with_capacity to avoid reallocations.

See OsStr introduction for more information about encoding.

Trait Implementations

impl From<String> for OsString

fn from(s: String) -> OsString

impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for OsString

fn from(s: &'a T) -> OsString

impl Index<RangeFull> for OsString

type Output = OsStr

fn index(&self, _index: RangeFull) -> &OsStr

impl Deref for OsString

type Target = OsStr

fn deref(&self) -> &OsStr

impl Default for OsString1.9.0

fn default() -> OsString

impl Debug for OsString

fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error>

impl PartialEq for OsString

fn eq(&self, other: &OsString) -> bool

fn ne(&self, other: &Rhs) -> bool

impl PartialEq<str> for OsString

fn eq(&self, other: &str) -> bool

fn ne(&self, other: &Rhs) -> bool

impl Eq for OsString

impl PartialOrd for OsString

fn partial_cmp(&self, other: &OsString) -> Option<Ordering>

fn lt(&self, other: &OsString) -> bool

fn le(&self, other: &OsString) -> bool

fn gt(&self, other: &OsString) -> bool

fn ge(&self, other: &OsString) -> bool

impl PartialOrd<str> for OsString

fn partial_cmp(&self, other: &str) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl Ord for OsString

fn cmp(&self, other: &OsString) -> Ordering

impl Hash for OsString

fn hash<H: Hasher>(&self, state: &mut H)

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher1.3.0

impl<'a, 'b> PartialEq<OsStr> for OsString1.8.0

fn eq(&self, other: &OsStr) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialOrd<OsStr> for OsString1.8.0

fn partial_cmp(&self, other: &OsStr) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialEq<&'a OsStr> for OsString1.8.0

fn eq(&self, other: &&'a OsStr) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialOrd<&'a OsStr> for OsString1.8.0

fn partial_cmp(&self, other: &&'a OsStr) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialEq<Cow<'a, OsStr>> for OsString1.8.0

fn eq(&self, other: &Cow<'a, OsStr>) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialOrd<Cow<'a, OsStr>> for OsString1.8.0

fn partial_cmp(&self, other: &Cow<'a, OsStr>) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl Borrow<OsStr> for OsString

fn borrow(&self) -> &OsStr

impl AsRef<OsStr> for OsString

fn as_ref(&self) -> &OsStr

impl OsStringExt for OsString

fn from_vec(vec: Vec<u8>) -> OsString

fn into_vec(self) -> Vec<u8>

impl AsRef<Path> for OsString

fn as_ref(&self) -> &Path

impl<'a, 'b> PartialEq<PathBuf> for OsString1.8.0

fn eq(&self, other: &PathBuf) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialOrd<PathBuf> for OsString1.8.0

fn partial_cmp(&self, other: &PathBuf) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialEq<Path> for OsString1.8.0

fn eq(&self, other: &Path) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialOrd<Path> for OsString1.8.0

fn partial_cmp(&self, other: &Path) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialEq<&'a Path> for OsString1.8.0

fn eq(&self, other: &&'a Path) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialOrd<&'a Path> for OsString1.8.0

fn partial_cmp(&self, other: &&'a Path) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialEq<Cow<'a, Path>> for OsString1.8.0

fn eq(&self, other: &Cow<'a, Path>) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<'a, 'b> PartialOrd<Cow<'a, Path>> for OsString1.8.0

fn partial_cmp(&self, other: &Cow<'a, Path>) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

Derived Implementations

impl Clone for OsString

fn clone(&self) -> OsString

fn clone_from(&mut self, source: &Self)