pub struct VendoredResolver { /* private fields */ }Expand description
Resolver that exposes the .mlua-pkgs/vendored/ directory to require.
VendoredResolver is a thin wrapper over FsResolver rooted at the
vendored_root directory (typically .mlua-pkgs/vendored/).
Each package in that directory is expected to be a symlink (or real
directory) created by the mlua-pkg install CLI (ST5). For example,
require("foo") resolves to vendored/foo/init.lua, and
require("foo.bar") resolves to vendored/foo/bar.lua.
§Responsibilities
- This resolver reads — it does not create symlinks or directories.
- The CLI creates —
mlua-pkg installis responsible for populating.mlua-pkgs/vendored/before this resolver is used.
§Construction
| Constructor | Use when |
|---|---|
VendoredResolver::from_lockfile | Normal usage: lockfile path + vendored root |
VendoredResolver::new | Low-level: vendored root already exists and is populated |
§Errors
new() returns InitError::RootNotFound if vendored_root does not exist.
from_lockfile() returns [PkgError::MissingLockfile] if the lockfile is absent,
or [PkgError::SameNameConflict] if duplicate package names are found.
Implementations§
Source§impl VendoredResolver
impl VendoredResolver
Sourcepub fn new(vendored_root: impl Into<PathBuf>) -> Result<Self, InitError>
pub fn new(vendored_root: impl Into<PathBuf>) -> Result<Self, InitError>
Low-level constructor: wrap an existing vendored_root directory.
Does not read a lockfile. Use from_lockfile
for the normal flow.
§Errors
Returns InitError::RootNotFound if vendored_root does not exist.
Sourcepub fn from_lockfile(
lockfile_path: impl AsRef<Path>,
vendored_root: impl AsRef<Path>,
) -> Result<Self, PkgError>
pub fn from_lockfile( lockfile_path: impl AsRef<Path>, vendored_root: impl AsRef<Path>, ) -> Result<Self, PkgError>
Normal constructor: read lockfile_path and wrap vendored_root.
Reads and validates the lockfile, then constructs an FsResolver
rooted at vendored_root. For each package in the lockfile, emits a
tracing::warn! if the corresponding vendored_root/<name> symlink or
directory is absent (the CLI has not yet installed that package).
Resolution will simply return None for missing packages at runtime,
matching normal FsResolver miss behaviour.
vendored_root is created automatically if it does not exist, to avoid
requiring a prior mlua-pkg install just to construct the resolver.
§Errors
| Error | Condition |
|---|---|
[PkgError::MissingLockfile] | lockfile_path does not exist |
[PkgError::LockfileParse] | Invalid TOML in the lockfile |
[PkgError::SameNameConflict] | Duplicate package names in the lockfile |
[PkgError::Io] | I/O failure while creating vendored_root or reading the lockfile |
Trait Implementations§
Source§impl Debug for VendoredResolver
impl Debug for VendoredResolver
Auto Trait Implementations§
impl !RefUnwindSafe for VendoredResolver
impl !UnwindSafe for VendoredResolver
impl Freeze for VendoredResolver
impl Send for VendoredResolver
impl Sync for VendoredResolver
impl Unpin for VendoredResolver
impl UnsafeUnpin for VendoredResolver
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> 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