wit_parser

Struct UnresolvedPackage

Source
pub struct UnresolvedPackage {
    pub name: PackageName,
    pub worlds: Arena<World>,
    pub interfaces: Arena<Interface>,
    pub types: Arena<TypeDef>,
    pub foreign_deps: IndexMap<PackageName, IndexMap<String, AstItem>>,
    pub docs: Docs,
    /* private fields */
}
Expand description

Representation of a parsed WIT package which has not resolved external dependencies yet.

This representation has performed internal resolution of the WIT package itself, ensuring that all references internally are valid and the WIT was syntactically valid and such.

The fields of this structure represent a flat list of arrays unioned from all documents within the WIT package. This means, for example, that all types from all documents are located in self.types. The fields of each item can help splitting back out into packages/interfaces/etc as necessary.

Note that an UnresolvedPackage cannot be queried in general about information such as size or alignment as that would require resolution of foreign dependencies. Translations such as to-binary additionally are not supported on an UnresolvedPackage due to the lack of knowledge about the foreign types. This is intended to be an intermediate state which can be inspected by embedders, if necessary, before quickly transforming to a Resolve to fully work with a WIT package.

After an UnresolvedPackage is parsed it can be fully resolved with Resolve::push. During this operation a dependency map is specified which will connect the foreign_deps field of this structure to packages previously inserted within the Resolve. Embedders are responsible for performing this resolution themselves.

Fields§

§name: PackageName

The namespace, name, and version information for this package.

§worlds: Arena<World>

All worlds from all documents within this package.

Each world lists the document that it is from.

§interfaces: Arena<Interface>

All interfaces from all documents within this package.

Each interface lists the document that it is from. Interfaces are listed in topological order as well so iteration through this arena will only reference prior elements already visited when working with recursive references.

§types: Arena<TypeDef>

All types from all documents within this package.

Each type lists the interface or world that defined it, or nothing if it’s an anonymous type. Types are listed in this arena in topological order to ensure that iteration through this arena will only reference other types transitively that are already iterated over.

§foreign_deps: IndexMap<PackageName, IndexMap<String, AstItem>>

All foreign dependencies that this package depends on.

These foreign dependencies must be resolved to convert this unresolved package into a Resolve. The map here is keyed by the name of the foreign package that this depends on, and the sub-map is keyed by an interface name followed by the identifier within self.interfaces. The fields of self.interfaces describes the required types that are from each foreign interface.

§docs: Docs

Doc comments for this package.

Trait Implementations§

Source§

impl Clone for UnresolvedPackage

Source§

fn clone(&self) -> UnresolvedPackage

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.