pub struct LuauModulePath { /* private fields */ }
Expand description
A resolved module path for Luau, containing both:
- The source Luau module path.
- The target filesystem path.
Note the separation here - the source is not necessarily a valid filesystem path, and the target is not necessarily a valid Luau module path for require-by-string.
See LuauFilePath
and LuauModulePath::resolve
for more information.
Implementations§
Source§impl LuauModulePath
impl LuauModulePath
Sourcepub fn strip(path: impl Into<PathBuf>) -> PathBuf
pub fn strip(path: impl Into<PathBuf>) -> PathBuf
Strips Luau file extensions and potential init segments from a given path.
This is the opposite operation of LuauModulePath::resolve
and is generally
useful for converting between paths in a CLI or other similar use cases - but
should never be used to implement require
resolution.
Does not use any filesystem calls and will not panic.
Sourcepub fn resolve(module: impl Into<PathBuf>) -> Result<Self, LuaNavigateError>
pub fn resolve(module: impl Into<PathBuf>) -> Result<Self, LuaNavigateError>
Resolves an existing file or directory path for the given module path.
Given a module path “path/to/module”, these files will be searched:
path/to/module.luau
path/to/module.lua
path/to/module/init.luau
path/to/module/init.lua
If the given path (“path/to/module”) is a directory instead, and it exists, it will be returned without any modifications.
§Errors
- If the given module path is ambiguous.
- If the given module path does not resolve to a valid file or directory.
Sourcepub fn target(&self) -> &LuauFilePath
pub fn target(&self) -> &LuauFilePath
Returns the target filesystem file path.
Trait Implementations§
Source§impl Clone for LuauModulePath
impl Clone for LuauModulePath
Source§fn clone(&self) -> LuauModulePath
fn clone(&self) -> LuauModulePath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for LuauModulePath
impl Debug for LuauModulePath
Source§impl Display for LuauModulePath
impl Display for LuauModulePath
Source§impl PartialEq for LuauModulePath
impl PartialEq for LuauModulePath
impl Eq for LuauModulePath
impl StructuralPartialEq for LuauModulePath
Auto Trait Implementations§
impl Freeze for LuauModulePath
impl RefUnwindSafe for LuauModulePath
impl Send for LuauModulePath
impl Sync for LuauModulePath
impl Unpin for LuauModulePath
impl UnwindSafe for LuauModulePath
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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