Struct wit_parser::Document
source · pub struct Document<'a> {
pub worlds: Vec<World>,
pub interfaces: Vec<Interface>,
/* private fields */
}Expand description
Represents the result of parsing a wit document.
Fields
worlds: Vec<World>The worlds contained in the document.
interfaces: Vec<Interface>The top-level interfaces contained in the document.
Implementations
sourceimpl<'a> Document<'a>
impl<'a> Document<'a>
sourcepub fn parse(path: &'a Path, contents: &'a str) -> Result<Self>
pub fn parse(path: &'a Path, contents: &'a str) -> Result<Self>
Parses the given string as a wit document.
The path argument is used for error reporting.
sourcepub fn into_world(self) -> Result<World>
pub fn into_world(self) -> Result<World>
Converts the document into a single world definition.
Returns an error if there were no worlds defined in the document or if there were multiple worlds defined.
sourcepub fn into_interface(self) -> Result<Interface>
pub fn into_interface(self) -> Result<Interface>
Converts the document into a single interface definition.
Returns an error if there were no worlds defined in the document or if there were multiple worlds defined.
Auto Trait Implementations
impl<'a> RefUnwindSafe for Document<'a>
impl<'a> Send for Document<'a>
impl<'a> Sync for Document<'a>
impl<'a> Unpin for Document<'a>
impl<'a> UnwindSafe for Document<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more