Struct path_abs::PathArc
[−]
[src]
pub struct PathArc(_);
A PathBuf
that is atomically reference counted and reimplements the PathBuf
methods to display the action and path when there is an error.
This is the root type of all other Path*
types in this crate.
This type is also serializable when the serialize
feature is enabled.
Methods
impl PathArc
[src]
pub fn new<P: AsRef<Path>>(path: P) -> PathArc
[src]
Instantiate a new PathArc
.
Examples
use path_abs::PathArc; let path = PathArc::new("some/path"); let path2 = path.clone(); // cloning is cheap
pub fn join<P: AsRef<Path>>(&self, path: P) -> PathArc
[src]
Creates an owned PathBuf with path adjoined to self.
This function is identical to std::path::PathBuf::join except
it returns PathArc
instead of PathBuf
pub fn with_file_name<P: AsRef<OsStr>>(&self, file_name: P) -> PathArc
[src]
Creates an owned PathArc
like self but with the given file name.
This function is identical to std::path::PathBuf::with_file_name except
it returns PathArc
instead of PathBuf
pub fn with_extension<P: AsRef<OsStr>>(&self, extension: P) -> PathArc
[src]
Creates an owned PathArc
like self but with the given extension.
This function is identical to std::path::PathBuf::with_extension except
it returns PathArc
instead of PathBuf
pub fn metadata(&self) -> Result<Metadata>
[src]
Queries the file system to get information about a file, directory, etc.
This function will traverse symbolic links to query information about the destination file.
This function is identical to std::path::Path::metadata except it has error messages which include the action and the path
pub fn symlink_metadata(&self) -> Result<Metadata>
[src]
Queries the metadata about a file without following symlinks.
This function is identical to std::path::Path::symlink_metadata except it has error messages which include the action and the path
pub fn canonicalize(&self) -> Result<PathAbs>
[src]
Returns the canonical form of the path with all intermediate components normalized and symbolic links resolved.
This function is identical to std::path::Path::canonicalize except:
- It returns a
PathAbs
object - It has error messages which include the action and the path
pub fn read_link(&self) -> Result<PathArc>
[src]
Reads a symbolic link, returning the file that the link points to.
This function is identical to std::path::Path::read_link except:
- It returns a
PathArc
object instead ofPathBuf
- It has error messages which include the action and the path
pub fn read_dir(&self) -> Result<ListDir>
[src]
Returns an iterator over the entries within a directory.
This function is a shortcut to PathDir::list
. It is slightly different
than std::path::Path::read_dir.
pub fn as_path(&self) -> &Path
[src]
Return a reference to a basic std::path::Path
pub fn absolute(&self) -> Result<PathAbs>
[src]
Convert the path to an absolute one, this is different from canonicalize
in that it
preserves symlinks and the destination may or may not exist.
This function will:
- Use
current_dir
to resolve relative paths. - Strip any
.
components (/a/./c
->/a/c
) - Resolve
..
semantically (not using the file system). So,a/b/c/../d => a/b/d
will always be true regardless of symlinks. If you want symlinks correctly resolved, usecanonicalize()
instead.
On windows, this will sometimes call
canonicalize()
on the first component to guarantee it is the correct canonicalized prefix. For paths starting with root it also has to get thecurrent_dir
On linux, the only syscall this will make is to get the
current_dir
for relative paths.
Methods from Deref<Target = PathBuf>
Trait Implementations
impl AsRef<PathArc> for PathAbs
[src]
impl Borrow<PathArc> for PathAbs
[src]
impl<'a> Borrow<PathArc> for &'a PathAbs
[src]
impl Into<PathArc> for PathAbs
[src]
impl Clone for PathArc
[src]
fn clone(&self) -> PathArc
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Eq for PathArc
[src]
impl Hash for PathArc
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for PathArc
[src]
fn eq(&self, __arg_0: &PathArc) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &PathArc) -> bool
[src]
This method tests for !=
.
impl PartialOrd for PathArc
[src]
fn partial_cmp(&self, __arg_0: &PathArc) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &PathArc) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &PathArc) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &PathArc) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &PathArc) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for PathArc
[src]
fn cmp(&self, __arg_0: &PathArc) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Debug for PathArc
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl AsRef<Path> for PathArc
[src]
impl AsRef<PathBuf> for PathArc
[src]
impl Borrow<Path> for PathArc
[src]
impl Borrow<PathBuf> for PathArc
[src]
impl<'a> Borrow<Path> for &'a PathArc
[src]
impl<'a> Borrow<PathBuf> for &'a PathArc
[src]
impl Deref for PathArc
[src]
type Target = PathBuf
The resulting type after dereferencing.
fn deref(&self) -> &PathBuf
[src]
Dereferences the value.
impl From<PathBuf> for PathArc
[src]
impl Into<PathBuf> for PathArc
[src]
fn into(self) -> PathBuf
[src]
If there is only one reference to the PathArc
, returns
the inner PathBuf
. Otherwise clones the inner PathBuf
.
This is useful when you really want a PathBuf
, especially
when the PathArc
was only recently created.
Examples
use path_abs::PathArc; use std::path::PathBuf; let base = PathArc::new("base"); let foo: PathBuf = base.join("foo.txt").into();
impl AsRef<PathArc> for PathDir
[src]
impl Borrow<PathArc> for PathDir
[src]
impl<'a> Borrow<PathArc> for &'a PathDir
[src]
impl Into<PathArc> for PathDir
[src]
impl AsRef<PathArc> for PathFile
[src]
impl Borrow<PathArc> for PathFile
[src]
impl<'a> Borrow<PathArc> for &'a PathFile
[src]
impl Into<PathArc> for PathFile
[src]
impl ToString for PathArc
[src]
impl FromStr for PathArc
[src]
type Err = DecodeError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<PathArc, DecodeError>
[src]
Convert STFU8 str
to a PathArc
.
impl Serialize for PathArc
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for PathArc
[src]
fn deserialize<D>(deserializer: D) -> Result<PathArc, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more