Skip to main content

DefaultModuleResolver

Struct DefaultModuleResolver 

Source
pub struct DefaultModuleResolver { /* private fields */ }
Expand description

The default resolver, combining standard library, local filesystem, and (optionally) HTTP sources.

Implementations§

Source§

impl DefaultModuleResolver

Source

pub fn new(paths: Vec<PathBuf>) -> Self

Creates a new resolver with the given filesystem search paths, backed by NativeIo for local module resolution, i.e. full, ungated disk access, matching this resolver’s historical behavior.

An empty paths slice falls back to the built-in default search directories.

Source

pub fn with_io(io: Shared<dyn Io>, paths: Vec<PathBuf>) -> Self

Creates a new resolver whose local filesystem module resolution goes through io instead of a bare NativeIo, e.g. a SandboxedIo so include/import respect the same read permission as the read_file/write_file/http builtins. HTTP module imports are unaffected (still NativeIo-only, if the http-import-ureq feature is enabled).

An empty paths slice falls back to the built-in default search directories.

Source

pub fn module_names(&self) -> Vec<String>

Names of the standard modules and the .mq files in the local search directories, sorted and without duplicates. Default search directories are used when none were given.

Trait Implementations§

Source§

impl Clone for DefaultModuleResolver

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DefaultModuleResolver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DefaultModuleResolver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ModuleResolver for DefaultModuleResolver

Source§

fn resolve(&self, module_name: &str) -> Result<String, ModuleError>

Returns the source content of module_name.
Source§

fn get_path(&self, module_name: &str) -> Result<String, ModuleError>

Returns the canonical path string for module_name (for diagnostics / LSP).
Source§

fn search_paths(&self) -> Vec<PathBuf>

Returns the filesystem directories this resolver searches.
Source§

fn set_search_paths(&mut self, paths: Vec<PathBuf>)

Replaces the filesystem search directories.
Source§

fn canonical_name<'a>(&self, module_path: &'a str) -> &'a str

Returns the short identifier to store the module under. Read more
Source§

fn is_immutable_module(&self, module_path: &str) -> bool

Whether this module’s source is embedded in the current binary and therefore cannot change during the lifetime of an Engine.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.