tvix_castore::import::archive

Type Alias TarPathBuf

source
type TarPathBuf = PathBuf;

Aliased Type§

struct TarPathBuf { /* private fields */ }

Implementations

source§

impl PathBuf

1.0.0 · source

pub fn new() -> PathBuf

Allocates an empty PathBuf.

§Examples
use std::path::PathBuf;

let path = PathBuf::new();
1.44.0 · source

pub fn with_capacity(capacity: usize) -> PathBuf

Creates a new PathBuf with a given capacity used to create the internal OsString. See with_capacity defined on OsString.

§Examples
use std::path::PathBuf;

let mut path = PathBuf::with_capacity(10);
let capacity = path.capacity();

// This push is done without reallocating
path.push(r"C:\");

assert_eq!(capacity, path.capacity());
1.0.0 · source

pub fn as_path(&self) -> &Path

Coerces to a Path slice.

§Examples
use std::path::{Path, PathBuf};

let p = PathBuf::from("/test");
assert_eq!(Path::new("/test"), p.as_path());
source

pub fn leak<'a>(self) -> &'a mut Path

🔬This is a nightly-only experimental API. (os_string_pathbuf_leak)

Consumes and leaks the PathBuf, returning a mutable reference to the contents, &'a mut Path.

The caller has free choice over the returned lifetime, including ’static. Indeed, this function is ideally used for data that lives for the remainder of the program’s life, as dropping the returned reference will cause a memory leak.

It does not reallocate or shrink the PathBuf, so the leaked allocation may include unused capacity that is not part of the returned slice. If you want to discard excess capacity, call into_boxed_path, and then Box::leak instead. However, keep in mind that trimming the capacity may result in a reallocation and copy.

1.0.0 · source

pub fn push<P>(&mut self, path: P)
where P: AsRef<Path>,

Extends self with path.

If path is absolute, it replaces the current path.

On Windows:

  • if path has a root but no prefix (e.g., \windows), it replaces everything except for the prefix (if any) of self.
  • if path has a prefix but no root, it replaces self.
  • if self has a verbatim prefix (e.g. \\?\C:\windows) and path is not empty, the new path is normalized: all references to . and .. are removed.

Consider using Path::join if you need a new PathBuf instead of using this function on a cloned PathBuf.

§Examples

Pushing a relative path extends the existing path:

use std::path::PathBuf;

let mut path = PathBuf::from("/tmp");
path.push("file.bk");
assert_eq!(path, PathBuf::from("/tmp/file.bk"));

Pushing an absolute path replaces the existing path:

use std::path::PathBuf;

let mut path = PathBuf::from("/tmp");
path.push("/etc");
assert_eq!(path, PathBuf::from("/etc"));
1.0.0 · source

pub fn pop(&mut self) -> bool

Truncates self to self.parent.

Returns false and does nothing if self.parent is None. Otherwise, returns true.

§Examples
use std::path::{Path, PathBuf};

let mut p = PathBuf::from("/spirited/away.rs");

p.pop();
assert_eq!(Path::new("/spirited"), p);
p.pop();
assert_eq!(Path::new("/"), p);
1.0.0 · source

pub fn set_file_name<S>(&mut self, file_name: S)
where S: AsRef<OsStr>,

Updates self.file_name to file_name.

If self.file_name was None, this is equivalent to pushing file_name.

Otherwise it is equivalent to calling pop and then pushing file_name. The new path will be a sibling of the original path. (That is, it will have the same parent.)

The argument is not sanitized, so can include separators. This behaviour may be changed to a panic in the future.

§Examples
use std::path::PathBuf;

let mut buf = PathBuf::from("/");
assert!(buf.file_name() == None);

buf.set_file_name("foo.txt");
assert!(buf == PathBuf::from("/foo.txt"));
assert!(buf.file_name().is_some());

buf.set_file_name("bar.txt");
assert!(buf == PathBuf::from("/bar.txt"));

buf.set_file_name("baz");
assert!(buf == PathBuf::from("/baz"));

buf.set_file_name("../b/c.txt");
assert!(buf == PathBuf::from("/../b/c.txt"));

buf.set_file_name("baz");
assert!(buf == PathBuf::from("/../b/baz"));
1.0.0 · source

pub fn set_extension<S>(&mut self, extension: S) -> bool
where S: AsRef<OsStr>,

Updates self.extension to Some(extension) or to None if extension is empty.

Returns false and does nothing if self.file_name is None, returns true and updates the extension otherwise.

If self.extension is None, the extension is added; otherwise it is replaced.

If extension is the empty string, self.extension will be None afterwards, not Some("").

§Panics

Panics if the passed extension contains a path separator (see is_separator).

§Caveats

The new extension may contain dots and will be used in its entirety, but only the part after the final dot will be reflected in self.extension.

If the file stem contains internal dots and extension is empty, part of the old file stem will be considered the new self.extension.

See the examples below.

§Examples
use std::path::{Path, PathBuf};

let mut p = PathBuf::from("/feel/the");

p.set_extension("force");
assert_eq!(Path::new("/feel/the.force"), p.as_path());

p.set_extension("dark.side");
assert_eq!(Path::new("/feel/the.dark.side"), p.as_path());

p.set_extension("cookie");
assert_eq!(Path::new("/feel/the.dark.cookie"), p.as_path());

p.set_extension("");
assert_eq!(Path::new("/feel/the.dark"), p.as_path());

p.set_extension("");
assert_eq!(Path::new("/feel/the"), p.as_path());

p.set_extension("");
assert_eq!(Path::new("/feel/the"), p.as_path());
source

pub fn add_extension<S>(&mut self, extension: S) -> bool
where S: AsRef<OsStr>,

🔬This is a nightly-only experimental API. (path_add_extension)

Append self.extension with extension.

Returns false and does nothing if self.file_name is None, returns true and updates the extension otherwise.

§Caveats

The appended extension may contain dots and will be used in its entirety, but only the part after the final dot will be reflected in self.extension.

See the examples below.

§Examples
#![feature(path_add_extension)]

use std::path::{Path, PathBuf};

let mut p = PathBuf::from("/feel/the");

p.add_extension("formatted");
assert_eq!(Path::new("/feel/the.formatted"), p.as_path());

p.add_extension("dark.side");
assert_eq!(Path::new("/feel/the.formatted.dark.side"), p.as_path());

p.set_extension("cookie");
assert_eq!(Path::new("/feel/the.formatted.dark.cookie"), p.as_path());

p.set_extension("");
assert_eq!(Path::new("/feel/the.formatted.dark"), p.as_path());

p.add_extension("");
assert_eq!(Path::new("/feel/the.formatted.dark"), p.as_path());
1.70.0 · source

pub fn as_mut_os_string(&mut self) -> &mut OsString

Yields a mutable reference to the underlying OsString instance.

§Examples
use std::path::{Path, PathBuf};

let mut path = PathBuf::from("/foo");

path.push("bar");
assert_eq!(path, Path::new("/foo/bar"));

// OsString's `push` does not add a separator.
path.as_mut_os_string().push("baz");
assert_eq!(path, Path::new("/foo/barbaz"));
1.0.0 · source

pub fn into_os_string(self) -> OsString

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();
1.20.0 · source

pub fn into_boxed_path(self) -> Box<Path>

Converts this PathBuf into a boxed Path.

1.44.0 · source

pub fn capacity(&self) -> usize

Invokes capacity on the underlying instance of OsString.

1.44.0 · source

pub fn clear(&mut self)

Invokes clear on the underlying instance of OsString.

1.44.0 · source

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

Invokes reserve on the underlying instance of OsString.

1.63.0 · source

pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

Invokes try_reserve on the underlying instance of OsString.

1.44.0 · source

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

Invokes reserve_exact on the underlying instance of OsString.

1.63.0 · source

pub fn try_reserve_exact( &mut self, additional: usize, ) -> Result<(), TryReserveError>

Invokes try_reserve_exact on the underlying instance of OsString.

1.44.0 · source

pub fn shrink_to_fit(&mut self)

Invokes shrink_to_fit on the underlying instance of OsString.

1.56.0 · source

pub fn shrink_to(&mut self, min_capacity: usize)

Invokes shrink_to on the underlying instance of OsString.

Trait Implementations

source§

impl Arg for PathBuf

source§

fn as_str(&self) -> Result<&str, Errno>

Returns a view of this string as a string slice.
source§

fn to_string_lossy(&self) -> Cow<'_, str>

Returns a potentially-lossy rendering of this string as a Cow<'_, str>.
source§

fn as_cow_c_str(&self) -> Result<Cow<'_, CStr>, Errno>

Returns a view of this string as a maybe-owned CStr.
source§

fn into_c_str<'b>(self) -> Result<Cow<'b, CStr>, Errno>
where PathBuf: 'b,

Consumes self and returns a view of this string as a maybe-owned CStr.
source§

fn into_with_c_str<T, F>(self, f: F) -> Result<T, Errno>
where PathBuf: Sized, F: FnOnce(&CStr) -> Result<T, Errno>,

Runs a closure with self passed in as a &CStr.
1.0.0 · source§

impl AsRef<OsStr> for PathBuf

source§

fn as_ref(&self) -> &OsStr

Converts this type into a shared reference of the (usually inferred) input type.
1.0.0 · source§

impl AsRef<Path> for PathBuf

source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
1.0.0 · source§

impl Borrow<Path> for PathBuf

source§

fn borrow(&self) -> &Path

Immutably borrows from an owned value. Read more
1.0.0 · source§

impl Clone for PathBuf

source§

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

Clones the contents of source into self.

This method is preferred over simply assigning source.clone() to self, as it avoids reallocation if possible.

source§

fn clone(&self) -> PathBuf

Returns a copy of the value. Read more
1.0.0 · source§

impl Debug for PathBuf

source§

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

Formats the value using the given formatter. Read more
1.17.0 · source§

impl Default for PathBuf

source§

fn default() -> PathBuf

Returns the “default value” for a type. Read more
1.0.0 · source§

impl Deref for PathBuf

source§

type Target = Path

The resulting type after dereferencing.
source§

fn deref(&self) -> &Path

Dereferences the value.
1.68.0 · source§

impl DerefMut for PathBuf

source§

fn deref_mut(&mut self) -> &mut Path

Mutably dereferences the value.
source§

impl<'de> Deserialize<'de> for PathBuf

source§

fn deserialize<D>( deserializer: D, ) -> Result<PathBuf, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
1.0.0 · source§

impl<P> Extend<P> for PathBuf
where P: AsRef<Path>,

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = P>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, p: P)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
1.0.0 · source§

impl<T> From<&T> for PathBuf
where T: AsRef<OsStr> + ?Sized,

source§

fn from(s: &T) -> PathBuf

Converts a borrowed OsStr to a PathBuf.

Allocates a PathBuf and copies the data into it.

1.18.0 · source§

impl From<Box<Path>> for PathBuf

source§

fn from(boxed: Box<Path>) -> PathBuf

Converts a Box<Path> into a PathBuf.

This conversion does not allocate or copy memory.

1.28.0 · source§

impl<'a> From<Cow<'a, Path>> for PathBuf

source§

fn from(p: Cow<'a, Path>) -> PathBuf

Converts a clone-on-write pointer to an owned path.

Converting from a Cow::Owned does not clone or allocate.

1.0.0 · source§

impl From<OsString> for PathBuf

source§

fn from(s: OsString) -> PathBuf

Converts an OsString into a PathBuf.

This conversion does not allocate or copy memory.

1.0.0 · source§

impl From<String> for PathBuf

source§

fn from(s: String) -> PathBuf

Converts a String into a PathBuf

This conversion does not allocate or copy memory.

1.0.0 · source§

impl<P> FromIterator<P> for PathBuf
where P: AsRef<Path>,

source§

fn from_iter<I>(iter: I) -> PathBuf
where I: IntoIterator<Item = P>,

Creates a value from an iterator. Read more
1.32.0 · source§

impl FromStr for PathBuf

source§

type Err = Infallible

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<PathBuf, <PathBuf as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.0.0 · source§

impl Hash for PathBuf

source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · source§

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

Feeds a slice of this type into the given Hasher. Read more
source§

impl NixPath for PathBuf

source§

fn is_empty(&self) -> bool

Is the path empty?
source§

fn len(&self) -> usize

Length of the path in bytes
source§

fn with_nix_path<T, F>(&self, f: F) -> Result<T, Errno>
where F: FnOnce(&CStr) -> T,

Execute a function with this path as a CStr. Read more
1.0.0 · source§

impl Ord for PathBuf

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
1.8.0 · source§

impl<'a> PartialEq<&'a OsStr> for PathBuf

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.6.0 · source§

impl<'a> PartialEq<&'a Path> for PathBuf

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.8.0 · source§

impl<'a> PartialEq<Cow<'a, OsStr>> for PathBuf

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.6.0 · source§

impl<'a> PartialEq<Cow<'a, Path>> for PathBuf

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.8.0 · source§

impl PartialEq<OsStr> for PathBuf

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.8.0 · source§

impl PartialEq<OsString> for PathBuf

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.6.0 · source§

impl PartialEq<Path> for PathBuf

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.0.0 · source§

impl PartialEq for PathBuf

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.8.0 · source§

impl<'a> PartialOrd<&'a OsStr> for PathBuf

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.8.0 · source§

impl<'a> PartialOrd<&'a Path> for PathBuf

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.8.0 · source§

impl<'a> PartialOrd<Cow<'a, OsStr>> for PathBuf

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.8.0 · source§

impl<'a> PartialOrd<Cow<'a, Path>> for PathBuf

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.8.0 · source§

impl PartialOrd<OsStr> for PathBuf

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.8.0 · source§

impl PartialOrd<OsString> for PathBuf

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.8.0 · source§

impl PartialOrd<Path> for PathBuf

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.0.0 · source§

impl PartialOrd for PathBuf

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for PathBuf

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TrieKey for PathBuf

source§

fn encode_bytes(&self) -> Vec<u8>

Encode a value as a vector of bytes.
source§

fn encode(&self) -> NibbleVec<[u8; 64]>

Encode a value as a NibbleVec.
1.0.0 · source§

impl Eq for PathBuf