Struct typst_syntax::FileId
source · pub struct FileId(/* private fields */);
Expand description
Identifies a file in a project or package.
This type is globally interned and thus cheap to copy, compare, and hash.
Implementations§
source§impl FileId
impl FileId
sourcepub fn new(package: Option<PackageSpec>, path: VirtualPath) -> Self
pub fn new(package: Option<PackageSpec>, path: VirtualPath) -> Self
Create a new interned file specification.
The path must start with a /
or this function will panic.
Note that the path is normalized before interning.
sourcepub fn new_fake(path: VirtualPath) -> Self
pub fn new_fake(path: VirtualPath) -> Self
Create a new unique (“fake”) file specification, which is not accessible by path.
Caution: the ID returned by this method is the only identifier of the file, constructing a file ID with a path will not reuse the ID even if the path is the same. This method should only be used for generating “virtual” file ids such as content read from stdin.
sourcepub fn package(&self) -> Option<&'static PackageSpec>
pub fn package(&self) -> Option<&'static PackageSpec>
The package the file resides in, if any.
sourcepub fn vpath(&self) -> &'static VirtualPath
pub fn vpath(&self) -> &'static VirtualPath
The absolute and normalized path to the file within the project or package.
Trait Implementations§
source§impl Ord for FileId
impl Ord for FileId
source§impl PartialEq for FileId
impl PartialEq for FileId
source§impl PartialOrd for FileId
impl PartialOrd for FileId
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 Copy for FileId
impl Eq for FileId
impl StructuralPartialEq for FileId
Auto Trait Implementations§
impl Freeze for FileId
impl RefUnwindSafe for FileId
impl Send for FileId
impl Sync for FileId
impl Unpin for FileId
impl UnwindSafe for FileId
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