pub struct SystemPath(/* private fields */);Expand description
An OS path kimün has made usable on this machine: absolute and
normalized (no . or .. components left).
Normalization is not cosmetic. A canonicalized Windows path is the verbatim
form \\?\C:\…, and Win32 reads every component of a verbatim path
literally — \\?\C:\kimun\. names a file called ., which no
create_dir_all and no SQLite open can use. Comparing two Paths hides
it (PartialEq goes through Components, which drops .), so only the
real filesystem call notices, on one platform, at runtime.
The invariant lives in the type because the alternative was tried: a
PathBuf that callers were told to resolve first, with a silent fallback
when they didn’t.
Implementations§
Source§impl SystemPath
impl SystemPath
Sourcepub fn try_absolute<P: AsRef<Path>>(path: P) -> Result<Self, SystemError>
pub fn try_absolute<P: AsRef<Path>>(path: P) -> Result<Self, SystemError>
Accepts an already-absolute path, normalizing it.
Rejects a relative path rather than resolving it against the process’s
working directory: that would make the result depend on where the
binary was launched, which is the failure this type exists to prevent.
Callers holding a relative path want SystemPath::resolve, which
makes them name the base.
Sourcepub fn resolve<P: AsRef<Path>>(path: P, base: &SystemPath) -> Self
pub fn resolve<P: AsRef<Path>>(path: P, base: &SystemPath) -> Self
Resolves a path that may be relative, may start with ~, and may not
exist yet, against base.
~ expands to the home directory (left as-is when there is none),
relative paths resolve against base, ./.. are removed, and the
result is canonicalized when it already exists on disk — the canonical
form is what later starts_with comparisons and the index’s stored
paths must agree with.
Sourcepub fn canonical<P: AsRef<Path>>(path: P) -> Result<Self, SystemError>
pub fn canonical<P: AsRef<Path>>(path: P) -> Result<Self, SystemError>
Resolves an existing path to its canonical form — symlinks followed,
./.. gone, absolute.
Fails when the path does not exist: canonicalization is the OS
answering “what is this really”, and there is no answer for something
that is not there. Callers resolving a path that may not exist yet want
SystemPath::resolve.
Sourcepub fn join<S: AsRef<Path>>(&self, segment: S) -> Self
pub fn join<S: AsRef<Path>>(&self, segment: S) -> Self
This path with segment appended, staying normalized (so a ..
segment cancels rather than accumulating).
Sourcepub fn with_name_suffix(&self, suffix: &str) -> Self
pub fn with_name_suffix(&self, suffix: &str) -> Self
This path with suffix appended to its file name — index.db plus
-wal is index.db-wal, not index.db/-wal and not index-wal.db.
How SQLite names the files beside a database.
Sourcepub fn as_path(&self) -> &Path
pub fn as_path(&self) -> &Path
Borrows the underlying OS path, for the standard library and for
callers that take AsRef<Path>.
Sourcepub fn into_path_buf(self) -> PathBuf
pub fn into_path_buf(self) -> PathBuf
Consumes this path, yielding the PathBuf.
Trait Implementations§
Source§impl AsRef<Path> for SystemPath
impl AsRef<Path> for SystemPath
Source§impl Clone for SystemPath
impl Clone for SystemPath
Source§fn clone(&self) -> SystemPath
fn clone(&self) -> SystemPath
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SystemPath
impl Debug for SystemPath
Source§impl Display for SystemPath
impl Display for SystemPath
impl Eq for SystemPath
Source§impl Hash for SystemPath
impl Hash for SystemPath
Source§impl Ord for SystemPath
impl Ord for SystemPath
Source§fn cmp(&self, other: &SystemPath) -> Ordering
fn cmp(&self, other: &SystemPath) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SystemPath
impl PartialEq for SystemPath
Source§impl PartialOrd for SystemPath
impl PartialOrd for SystemPath
impl StructuralPartialEq for SystemPath
Auto Trait Implementations§
impl Freeze for SystemPath
impl RefUnwindSafe for SystemPath
impl Send for SystemPath
impl Sync for SystemPath
impl Unpin for SystemPath
impl UnsafeUnpin for SystemPath
impl UnwindSafe for SystemPath
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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§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 more