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

PathBuf

Struct PathBuf 

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

An owned, validated path for hierarchical document access.

PathBuf provides a type-safe way to construct and manipulate paths for accessing nested structures in CRDT documents. It validates that paths are well-formed and provides efficient access to path component.

§Examples

// Create from string (automatically normalized)
let path = PathBuf::from_str("user.profile.name")?;

// Build incrementally (infallible)
let path = PathBuf::new()
    .push("user")
    .push("profile")
    .push("name");

// Get components
let components: Vec<&str> = path.components().collect();
assert_eq!(components, vec!["user", "profile", "name"]);

Implementations§

Source§

impl PathBuf

Source

pub fn new() -> Self

Creates a new empty path.

Source

pub fn from_component(component: Component) -> Self

Creates a path from a single component.

Source

pub fn push(self, path: impl AsRef<str>) -> Self

Adds a path to the end of this path.

This method accepts both strings and Path types, normalizing the input. It’s infallible and handles all path joining cases through normalization.

§Examples
// Push strings
let path = PathBuf::new().push("user").push("profile");
assert_eq!(path.as_str(), "user.profile");

// Push Path types
let suffix = PathBuf::from_str("name.value").unwrap();
let path = PathBuf::new().push("user").push(&suffix);
assert_eq!(path.as_str(), "user.name.value");
Source

pub fn push_component(self, component: Component) -> Self

Adds a validated component to the end of this path.

Source

pub fn join(self, other: impl AsRef<Path>) -> Self

Joins this path with another path.

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 parent(&self) -> Option<PathBuf>

Returns the parent path, or None if this is the root.

Source

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

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

Source

pub fn normalize(path: &str) -> Self

Creates a PathBuf by normalizing the input string.

This method always succeeds by applying path normalization rules.

Methods from Deref<Target = Path>§

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 PathBuf

Source§

fn as_ref(&self) -> &Path

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

impl AsRef<PathBuf> for PathBuf

Source§

fn as_ref(&self) -> &PathBuf

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

impl AsRef<str> for PathBuf

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 Clone for PathBuf

Source§

fn clone(&self) -> PathBuf

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PathBuf

Source§

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

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

impl Default for PathBuf

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for PathBuf

Source§

type Target = Path

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Display for PathBuf

Source§

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

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

impl From<&PathBuf> for PathBuf

Source§

fn from(path: &PathBuf) -> Self

Converts to this type from the input type.
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<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStrResult for PathBuf

Source§

impl Hash for PathBuf

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

impl Eq for PathBuf

Source§

impl StructuralPartialEq for PathBuf

Auto Trait Implementations§

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
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<M> Meta for M
where M: Default,