Skip to main content

Path

Struct Path 

Source
pub struct Path { /* private fields */ }
Expand description

A validated logical path independent of any provider-native representation.

§Examples

use qubit_fs::Path;
use qubit_fs::path::RelativePath;
let root = Path::parse("/reports")?;
let report = root.join(&RelativePath::parse("daily.csv")?);
assert_eq!("/reports/daily.csv", report.as_str());
assert!(report.is_absolute());

Implementations§

Source§

impl Path

Source

pub fn root() -> Self

Creates the canonical hierarchical root path.

Source

pub fn from_components<I, S>(absolute: bool, components: I) -> FsResult<Self>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Constructs a hierarchical path from independently validated components.

Each item is validated as one component without reparsing a joined path string. An empty absolute sequence produces the root; an empty relative sequence returns an invalid-path error.

§Parameters
  • absolute: Whether the resulting path is rooted at the provider root.
  • components: Validated path-component text to join in order.
§Errors

Returns an invalid-path error when a component is empty, contains a separator or traversal marker, or when a relative sequence is empty.

Source

pub fn parse(text: &str) -> FsResult<Self>

Parses a hierarchical logical path using normalized semantics.

Returns an invalid-path error for empty input, NUL, or root escape.

§Errors

Returns FsError with an invalid-path kind when text is empty, contains NUL, or escapes above the hierarchical root.

Source

pub fn parse_literal(text: &str) -> FsResult<Self>

Parses a provider-literal path without interpreting separators or dots.

Returns an invalid-path error for empty input or NUL.

§Errors

Returns FsError with an invalid-path kind when text is empty or contains NUL.

Source

pub fn parse_with_semantics( text: &str, semantics: PathSemantics, ) -> FsResult<Self>

Parses text according to explicitly selected provider semantics.

Hierarchical values normalize empty and dot components and reject root escapes. Object-key and provider-specific values preserve their text.

§Parameters
  • text: Provider path text to validate and normalize.
  • semantics: Path semantics controlling normalization and root rules.
§Errors

Returns an invalid-path error when text is empty, contains NUL, or escapes above the hierarchical root.

Source

pub fn as_str(&self) -> &str

Returns the validated logical path text.

Source

pub fn file_name(&self) -> Option<&str>

Returns the final non-empty path component, when one is present.

A root path and a literal path ending in a separator have no file name. Hierarchical paths are canonicalized during parsing, so their final component is always non-empty.

§Returns

Some with the final non-empty component, or None for a root or a literal path ending in a separator.

Source

pub const fn is_absolute(&self) -> bool

Returns whether this path is absolute.

Source

pub const fn semantics(&self) -> PathSemantics

Returns the semantics used to validate this logical path.

Source

pub fn components(&self) -> PathComponents<'_> ⓘ

Iterates lexical component boundaries without using an empty root value.

Source

pub fn child(&self, component: &PathComponent) -> Self

Appends one validated component without re-parsing provider text.

Source

pub fn join(&self, relative: &RelativePath) -> Self

Appends a safe normalized relative path without re-parsing provider text.

Trait Implementations§

Source§

impl AsRef<str> for Path

Source§

fn as_ref(&self) -> &str

Returns the logical path text for generic text consumers.

Source§

impl Clone for Path

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Path

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Path

Source§

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

Formats the validated logical spelling.

Source§

impl Eq for Path

Source§

impl Hash for Path

Source§

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

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

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Path

Auto Trait Implementations§

§

impl Freeze for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl Sync for Path

§

impl Unpin for Path

§

impl UnsafeUnpin for Path

§

impl UnwindSafe for Path

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.