Struct ergo_fs::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]
fn new<P>(path: P) -> PathArc where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Instantiate a new PathArc
.
Examples
use path_abs::PathArc; let path = PathArc::new("some/path"); let path2 = path.clone(); // cloning is cheap
fn join<P>(&self, path: P) -> PathArc where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
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
fn with_file_name<P>(&self, file_name: P) -> PathArc where
P: AsRef<OsStr>,
[src]
P: AsRef<OsStr>,
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
fn with_extension<P>(&self, extension: P) -> PathArc where
P: AsRef<OsStr>,
[src]
P: AsRef<OsStr>,
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
fn metadata(&self) -> Result<Metadata, Error>
[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
fn symlink_metadata(&self) -> Result<Metadata, Error>
[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
fn canonicalize(&self) -> Result<PathAbs, Error>
[src]
Returns the canonical form of the path with all intermediate components normalized and symbolic links resolved.
This is identical to
PathAbs::new(path)
.
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
fn read_link(&self) -> Result<PathArc, Error>
[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 of PathBuf
- It has error messages which include the action and the path
fn read_dir(&self) -> Result<ListDir, Error>
[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.
fn as_path(&self) -> &Path
[src]
Return a reference to a basic std::path::Path
Methods from Deref<Target = PathBuf>
fn as_path(&self) -> &Path
1.0.0[src]
Coerces to a Path
slice.
Examples
use std::path::{Path, PathBuf}; let p = PathBuf::from("/test"); assert_eq!(Path::new("/test"), p.as_path());
fn into_os_string(self) -> OsString
1.0.0[src]
Consumes the PathBuf
, yielding its internal OsString
storage.
Examples
use std::path::PathBuf; let p = PathBuf::from("/the/head"); let os_str = p.into_os_string();
fn into_boxed_path(self) -> Box<Path>
1.20.0[src]
Trait Implementations
impl Serialize for PathArc
[src]
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
[src]
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
impl Ord for PathArc
[src]
impl Hash for PathArc
[src]
fn hash<__H>(&self, __arg_0: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
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 Clone for PathArc
[src]
impl Eq for 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 AsRef<PathBuf> for PathArc
[src]
impl AsRef<Path> for PathArc
[src]
impl PartialEq<PathArc> for PathArc
[src]
impl Debug for PathArc
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl<'de> Deserialize<'de> for PathArc
[src]
fn deserialize<D>(
deserializer: D
) -> Result<PathArc, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
[src]
deserializer: D
) -> Result<PathArc, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
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();