Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica

Path

Struct Path 

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

A borrowed, validated path for hierarchical document access.

Path is the borrowed counterpart to PathBuf, similar to how &str relates to String. It provides efficient read-only access to path components without allocation.

This type is unsized and must always be used behind a reference.

Implementations§

Source§

impl Path

Source

pub fn new(s: &str) -> &Path

Creates a Path from a string slice.

This is a zero-cost operation that wraps the string without validation or normalization. Normalization happens during path processing operations when needed.

This follows the same pattern as std::path::Path::new().

Source

pub unsafe fn from_str_unchecked(s: &str) -> &Path

Creates a Path from a string without validation.

§Safety

The caller must ensure that the string is a valid path according to our validation rules:

  • No leading or trailing dots
  • No empty components (consecutive dots)
  • Components may not contain dots

This is primarily intended for use with compile-time validated string literals.

Source

pub fn components(&self) -> impl Iterator<Item = &str>

Returns an iterator over the path components as string slices.

Source

pub fn len(&self) -> usize

Returns the number of components in the path.

Source

pub fn is_empty(&self) -> bool

Returns true if the path has no components.

Source

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

Returns the last component of the path, or None if empty.

Source

pub fn as_str(&self) -> &str

Returns the path as a string slice.

Source

pub fn to_path_buf(&self) -> PathBuf

Converts this Path to an owned PathBuf.

Trait Implementations§

Source§

impl AsRef<Path> for Path

Source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
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.
Source§

impl AsRef<Path> for String

Source§

fn as_ref(&self) -> &Path

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

impl AsRef<Path> for str

Source§

fn as_ref(&self) -> &Path

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

impl AsRef<str> for Path

Source§

fn as_ref(&self) -> &str

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

impl Borrow<Path> for PathBuf

Source§

fn borrow(&self) -> &Path

Immutably borrows from an owned value. 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, f: &mut Formatter<'_>) -> Result

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

impl Hash for Path

Source§

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

Feeds this value into the given Hasher. Read more
Source§

impl PartialEq for Path

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.
Source§

impl Eq for Path

Source§

impl StructuralPartialEq for Path

Auto Trait Implementations§

§

impl Freeze for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl !Sized for Path

§

impl Sync for Path

§

impl Unpin 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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. 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