Struct tvix_castore::PathBuf
source · pub struct PathBuf {
inner: Vec<u8>,
}
Expand description
Represents a owned PathBuf in the castore model. These are always relative, and platform-independent, which distinguishes them from the ones provided in the standard library.
Fields§
§inner: Vec<u8>
Implementations§
source§impl PathBuf
impl PathBuf
pub fn new() -> PathBuf
pub fn with_capacity(capacity: usize) -> PathBuf
sourceunsafe fn from_bytes_unchecked(bytes: Vec<u8>) -> PathBuf
unsafe fn from_bytes_unchecked(bytes: Vec<u8>) -> PathBuf
Convert a byte vector to a PathBuf, without checking validity.
sourcepub fn from_host_path(
host_path: &Path,
canonicalize_dotdot: bool,
) -> Result<Self, Error>
pub fn from_host_path( host_path: &Path, canonicalize_dotdot: bool, ) -> Result<Self, Error>
Convert from a [&std::path::Path] to Self.
- Self uses
/
as path separator. - Absolute paths are always rejected, are are these with custom prefixes.
- Repeated separators are deduplicated.
- Occurrences of
.
are normalized away. - A trailing slash is normalized away.
A canonicalize_dotdot
boolean controls whether ..
will get
canonicalized if possible, or should return an error.
For more exotic paths, this conversion might produce different results on different platforms, due to different underlying byte representations, which is why it’s restricted to unix for now.
pub fn into_boxed_path(self) -> Box<Path>
pub fn into_bytes(self) -> Vec<u8> ⓘ
Methods from Deref<Target = Path>§
pub const ROOT: &'static Path = _
sourcepub fn parent(&self) -> Option<&Path>
pub fn parent(&self) -> Option<&Path>
Returns the path without its final component, if there is one.
Note that the parent of a bare file name is Path::ROOT. Path::ROOT is the only path without a parent.
sourcepub fn try_join(&self, name: &[u8]) -> Result<PathBuf, Error>
pub fn try_join(&self, name: &[u8]) -> Result<PathBuf, Error>
Creates a PathBuf with name
adjoined to self.
sourcepub fn components(&self) -> impl Iterator<Item = PathComponent> + '_
pub fn components(&self) -> impl Iterator<Item = PathComponent> + '_
Provides an iterator over the components of the path, which are invividual PathComponent. In case the path is empty, an empty iterator is returned.
sourcepub fn components_bytes(&self) -> impl Iterator<Item = &[u8]>
pub fn components_bytes(&self) -> impl Iterator<Item = &[u8]>
Produces an iterator over the components of the path, which are individual byte slices. In case the path is empty, an empty iterator is returned.
sourcepub fn file_name(&self) -> Option<PathComponent>
pub fn file_name(&self) -> Option<PathComponent>
Returns the final component of the Path, if there is one, in bytes.
sourcepub fn file_name_bytes(&self) -> Option<&[u8]>
pub fn file_name_bytes(&self) -> Option<&[u8]>
Returns the final component of the Path, if there is one, in bytes.
pub fn as_bytes(&self) -> &[u8] ⓘ
Trait Implementations§
source§impl PartialEq for PathBuf
impl PartialEq for PathBuf
impl Eq for PathBuf
impl StructuralPartialEq for PathBuf
Auto Trait Implementations§
impl Freeze for PathBuf
impl RefUnwindSafe for PathBuf
impl Send for PathBuf
impl Sync for PathBuf
impl Unpin for PathBuf
impl UnwindSafe for PathBuf
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request