pub struct VirtualResolver<'a> { /* private fields */ }Expand description
A resolver that resolves in-memory modules added with Self::add_module.
Use-cases are platforms that lack a filesystem (e.g. WASM), tests or runtime-generated files.
Implementations§
Source§impl<'a> VirtualResolver<'a>
impl<'a> VirtualResolver<'a>
Sourcepub fn add_module(&mut self, path: ModulePath, file: Cow<'a, str>)
pub fn add_module(&mut self, path: ModulePath, file: Cow<'a, str>)
Resolve imports of path with the given WESL string.
The path must not be relative.
Sourcepub fn add_translation_unit(
&mut self,
path: ModulePath,
translation_unit: TranslationUnit,
)
pub fn add_translation_unit( &mut self, path: ModulePath, translation_unit: TranslationUnit, )
Resolve imports of path with the given TranslationUnit.
The path must not be relative.
Sourcepub fn get_module(&self, path: &ModulePath) -> Result<&str, ResolveError>
pub fn get_module(&self, path: &ModulePath) -> Result<&str, ResolveError>
Get a module registered with Self::add_module.
Sourcepub fn modules(&self) -> impl Iterator<Item = (&ModulePath, &str)>
pub fn modules(&self) -> impl Iterator<Item = (&ModulePath, &str)>
Iterate over all registered modules.
Trait Implementations§
Source§impl<'a> Default for VirtualResolver<'a>
impl<'a> Default for VirtualResolver<'a>
Source§fn default() -> VirtualResolver<'a>
fn default() -> VirtualResolver<'a>
Returns the “default value” for a type. Read more
Source§impl Resolver for VirtualResolver<'_>
impl Resolver for VirtualResolver<'_>
Source§fn resolve_source<'b>(
&'b self,
path: &ModulePath,
) -> Result<Cow<'b, str>, ResolveError>
fn resolve_source<'b>( &'b self, path: &ModulePath, ) -> Result<Cow<'b, str>, ResolveError>
Try to resolve a source file identified by a module path.
Source§fn display_name(&self, _path: &ModulePath) -> Option<String>
fn display_name(&self, _path: &ModulePath) -> Option<String>
Get the display name of the module path. Implementing this is optional.
Source§fn fs_path(&self, _module_path: &ModulePath) -> Result<PathBuf, ResolveError>
fn fs_path(&self, _module_path: &ModulePath) -> Result<PathBuf, ResolveError>
Get the filesystem path of the module path. Implementing this is optional.
Source§fn module_path(&self, _fs_path: &Path) -> Result<ModulePath, ResolveError>
fn module_path(&self, _fs_path: &Path) -> Result<ModulePath, ResolveError>
Get the module path of the filesystem path. Implementing this is optional.
Source§fn canonical_path(&self, path: &ModulePath) -> ModulePath
fn canonical_path(&self, path: &ModulePath) -> ModulePath
Get the canonical form of a module path.
Auto Trait Implementations§
impl<'a> Freeze for VirtualResolver<'a>
impl<'a> RefUnwindSafe for VirtualResolver<'a>
impl<'a> Send for VirtualResolver<'a>
impl<'a> Sync for VirtualResolver<'a>
impl<'a> Unpin for VirtualResolver<'a>
impl<'a> UnsafeUnpin for VirtualResolver<'a>
impl<'a> UnwindSafe for VirtualResolver<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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 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> ⓘ
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