Struct std::old_path::windows::PathUnstable [-] [+] [src]

pub struct Path {
    // some fields omitted
}

Represents a Windows path

Methods

impl Path

fn new<T: BytesContainer>(path: T) -> Path

Returns a new Path from a BytesContainer.

Panics

Panics if the vector contains a NUL, or if it contains invalid UTF-8.

Example

fn main() { println!("{}", Path::new(r"C:\some\path").display()); }
println!("{}", Path::new(r"C:\some\path").display());

fn new_opt<T: BytesContainer>(path: T) -> Option<Path>

Returns a new Some(Path) from a BytesContainer.

Returns None if the vector contains a NUL, or if it contains invalid UTF-8.

Example

fn main() { let path = Path::new_opt(r"C:\some\path"); match path { Some(path) => println!("{}", path.display()), None => println!("There was a problem with your path."), } }
let path = Path::new_opt(r"C:\some\path");

match path {
    Some(path) => println!("{}", path.display()),
    None       => println!("There was a problem with your path."),
}

fn str_components<'a>(&'a self) -> StrComponents<'a>

Returns an iterator that yields each component of the path in turn as a Option<&str>. Every component is guaranteed to be Some. Does not yield the path prefix (including server/share components in UNC paths). Does not distinguish between volume-relative and relative paths, e.g. \a\b\c and a\b\c. Does not distinguish between absolute and cwd-relative paths, e.g. C:\foo and C:foo.

fn components<'a>(&'a self) -> Components<'a>

Returns an iterator that yields each component of the path in turn as a &[u8]. See str_components() for details.

Trait Implementations

impl Debug for Path

fn fmt(&self, f: &mut Formatter) -> Result

impl PartialEq for Path

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

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

impl Eq for Path

impl PartialOrd for Path

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 Ord for Path

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

impl FromStr for Path

type Err = ParsePathError

fn from_str(s: &str) -> Result<Path, ParsePathError>

impl Hash for Path

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

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

impl BytesContainer for Path

fn container_as_bytes<'a>(&'a self) -> &'a [u8]

fn container_as_str<'a>(&'a self) -> Option<&'a str>

fn is_str(_: Option<&Path>) -> bool

impl GenericPathUnsafe for Path

unsafe fn new_unchecked<T: BytesContainer>(path: T) -> Path

See GenericPathUnsafe::from_vec_unchecked.

Panics

Panics if not valid UTF-8.

unsafe fn set_filename_unchecked<T: BytesContainer>(&mut self, filename: T)

See GenericPathUnsafe::set_filename_unchecked.

Panics

Panics if not valid UTF-8.

unsafe fn push_unchecked<T: BytesContainer>(&mut self, path: T)

See GenericPathUnsafe::push_unchecked.

Concatenating two Windows Paths is rather complicated. For the most part, it will behave as expected, except in the case of pushing a volume-relative path, e.g. C:foo.txt. Because we have no concept of per-volume cwds like Windows does, we can't behave exactly like Windows will. Instead, if the receiver is an absolute path on the same volume as the new path, it will be treated as the cwd that the new path is relative to. Otherwise, the new path will be treated as if it were absolute and will replace the receiver outright.

impl GenericPath for Path

fn new_opt<T: BytesContainer>(path: T) -> Option<Path>

fn as_str<'a>(&'a self) -> Option<&'a str>

See GenericPath::as_str for info. Always returns a Some value.

fn as_vec<'a>(&'a self) -> &'a [u8]

fn into_vec(self) -> Vec<u8>

fn dirname<'a>(&'a self) -> &'a [u8]

fn dirname_str<'a>(&'a self) -> Option<&'a str>

See GenericPath::dirname_str for info. Always returns a Some value.

fn filename<'a>(&'a self) -> Option<&'a [u8]>

fn filename_str<'a>(&'a self) -> Option<&'a str>

See GenericPath::filename_str for info. Always returns a Some value if filename returns a Some value.

fn filestem_str<'a>(&'a self) -> Option<&'a str>

See GenericPath::filestem_str for info. Always returns a Some value if filestem returns a Some value.

fn extension_str<'a>(&'a self) -> Option<&'a str>

fn dir_path(&self) -> Path

fn pop(&mut self) -> bool

fn root_path(&self) -> Option<Path>

fn is_absolute(&self) -> bool

See GenericPath::is_absolute for info.

A Windows Path is considered absolute only if it has a non-volume prefix, or if it has a volume prefix and the path starts with '\'. A path of \foo is not considered absolute because it's actually relative to the "current volume". A separate method Path::is_vol_relative is provided to indicate this case. Similarly a path of C:foo is not considered absolute because it's relative to the cwd on volume C:. A separate method Path::is_cwd_relative is provided to indicate this case.

fn is_relative(&self) -> bool

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

fn path_relative_from(&self, base: &Path) -> Option<Path>

fn ends_with_path(&self, child: &Path) -> bool

fn new<T: BytesContainer>(path: T) -> Self

fn display<'a>(&'a self) -> Display<'a, Self>

fn filename_display<'a>(&'a self) -> Display<'a, Self>

fn filestem<'a>(&'a self) -> Option<&'a [u8]>

fn extension<'a>(&'a self) -> Option<&'a [u8]>

fn set_filename<T: BytesContainer>(&mut self, filename: T)

fn set_extension<T: BytesContainer>(&mut self, extension: T)

fn with_filename<T: BytesContainer>(&self, filename: T) -> Self

fn with_extension<T: BytesContainer>(&self, extension: T) -> Self

fn push<T: BytesContainer>(&mut self, path: T)

fn push_many<T: BytesContainer>(&mut self, paths: &[T])

fn join<T: BytesContainer>(&self, path: T) -> Self

fn join_many<T: BytesContainer>(&self, paths: &[T]) -> Self

Derived Implementations

impl Clone for Path

fn clone(&self) -> Path

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