Struct wit_parser::SourceMap
source · pub struct SourceMap { /* private fields */ }
Expand description
A listing of source files which are used to get parsed into an
UnresolvedPackage
.
Implementations§
source§impl SourceMap
impl SourceMap
sourcepub fn push_file(&mut self, path: &Path) -> Result<()>
pub fn push_file(&mut self, path: &Path) -> Result<()>
Reads the file path
on the filesystem and appends its contents to this
SourceMap
.
This method pushes a new document into the source map. The name of the
document is derived from the filename of the path
provided.
sourcepub fn push(&mut self, path: &Path, name: &str, contents: impl Into<String>)
pub fn push(&mut self, path: &Path, name: &str, contents: impl Into<String>)
Appends the given contents with the given path into this source map.
Each path added to a SourceMap
will become a document in the final
package. The path
provided is not read from the filesystem and is
instead only used during error messages. The name
provided is the name
of the document within the WIT package and must be a valid WIT
identifier.
sourcepub fn parse(self, name: &str, url: Option<&str>) -> Result<UnresolvedPackage>
pub fn parse(self, name: &str, url: Option<&str>) -> Result<UnresolvedPackage>
Parses the files added to this source map into an UnresolvedPackage
.
All files previously added are considered documents of the package to be returned.
sourcepub fn source_files(&self) -> impl Iterator<Item = &Path>
pub fn source_files(&self) -> impl Iterator<Item = &Path>
Returns an iterator over all filenames added to this source map.