Struct typst_syntax::VirtualPath
source · pub struct VirtualPath(/* private fields */);
Expand description
An absolute path in the virtual file system of a project or package.
Implementations§
source§impl VirtualPath
impl VirtualPath
sourcepub fn new(path: impl AsRef<Path>) -> Self
pub fn new(path: impl AsRef<Path>) -> Self
Create a new virtual path.
Even if it doesn’t start with /
or \
, it is still interpreted as
starting from the root.
sourcepub fn within_root(path: &Path, root: &Path) -> Option<Self>
pub fn within_root(path: &Path, root: &Path) -> Option<Self>
Create a virtual path from a real path and a real root.
Returns None
if the file path is not contained in the root (i.e. if
root
is not a lexical prefix of path
). No file system operations are
performed.
sourcepub fn as_rooted_path(&self) -> &Path
pub fn as_rooted_path(&self) -> &Path
Get the underlying path with a leading /
or \
.
sourcepub fn as_rootless_path(&self) -> &Path
pub fn as_rootless_path(&self) -> &Path
Get the underlying path without a leading /
or \
.
Trait Implementations§
source§impl Clone for VirtualPath
impl Clone for VirtualPath
source§fn clone(&self) -> VirtualPath
fn clone(&self) -> VirtualPath
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for VirtualPath
impl Debug for VirtualPath
source§impl Hash for VirtualPath
impl Hash for VirtualPath
source§impl Ord for VirtualPath
impl Ord for VirtualPath
source§fn cmp(&self, other: &VirtualPath) -> Ordering
fn cmp(&self, other: &VirtualPath) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for VirtualPath
impl PartialEq for VirtualPath
source§fn eq(&self, other: &VirtualPath) -> bool
fn eq(&self, other: &VirtualPath) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for VirtualPath
impl PartialOrd for VirtualPath
source§fn partial_cmp(&self, other: &VirtualPath) -> Option<Ordering>
fn partial_cmp(&self, other: &VirtualPath) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for VirtualPath
impl StructuralPartialEq for VirtualPath
Auto Trait Implementations§
impl Freeze for VirtualPath
impl RefUnwindSafe for VirtualPath
impl Send for VirtualPath
impl Sync for VirtualPath
impl Unpin for VirtualPath
impl UnwindSafe for VirtualPath
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
Mutably borrows from an owned value. Read more