pub struct Script { /* private fields */ }Expand description
Types for working with JS script. Represents a JavaScript immutable handler script with metadata about its source location. The source location metadata is required to resolve relative locations when the script imports other modules using relative paths.
Implementations§
Source§impl Script
impl Script
Sourcepub fn from_content(content: impl Into<String>) -> Self
pub fn from_content(content: impl Into<String>) -> Self
Create a script from a string with no base path for module resolution
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self>
Create a script by reading from a file
The base path is automatically set to the directory containing the file
Sourcepub fn with_virtual_base(self, path: impl AsRef<str>) -> Self
pub fn with_virtual_base(self, path: impl AsRef<str>) -> Self
Set a virtual base path for module resolution.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Script
impl RefUnwindSafe for Script
impl Send for Script
impl Sync for Script
impl Unpin for Script
impl UnsafeUnpin for Script
impl UnwindSafe for Script
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