Struct WitPrinter

Source
pub struct WitPrinter<O: Output = OutputToString> {
    pub output: O,
    /* private fields */
}
Expand description

A utility for printing WebAssembly interface definitions to a string.

Fields§

§output: O

Visitor that holds the WIT document being printed.

Implementations§

Source§

impl<O: Output> WitPrinter<O>

Source

pub fn new(output: O) -> Self

Craete new instance.

Source

pub fn print( &mut self, resolve: &Resolve, pkg: PackageId, nested: &[PackageId], ) -> Result<()>

Prints the specified pkg which is located in resolve to O.

The nested list of packages are other packages to include at the end of the output in package ... { ... } syntax.

Source

pub fn emit_docs(&mut self, enabled: bool) -> &mut Self

Configure whether doc comments will be printed.

Defaults to true.

Source

pub fn print_package( &mut self, resolve: &Resolve, pkg: PackageId, is_main: bool, ) -> Result<()>

Prints the specified pkg.

If is_main is not set, nested package notation is used.

Source

pub fn print_package_outer(&mut self, pkg: &Package) -> Result<()>

Print the specified package without its content. Does not print the semicolon nor starts the indentation.

Source

pub fn print_interface_outer( &mut self, resolve: &Resolve, id: InterfaceId, name: &str, ) -> Result<()>

Print the given WebAssembly interface without its content. Does not print the semicolon nor starts the indentation.

Source

pub fn print_interface( &mut self, resolve: &Resolve, id: InterfaceId, ) -> Result<()>

Print the inner content of a given WebAssembly interface.

Source

pub fn print_types<'a>( &mut self, resolve: &Resolve, owner: TypeOwner, types: impl Iterator<Item = (&'a str, TypeId)>, resource_funcs: &HashMap<TypeId, Vec<&Function>>, ) -> Result<()>

Print types of an interface.

Source

pub fn print_type_name(&mut self, resolve: &Resolve, ty: &Type) -> Result<()>

Print the name of type ty.

Trait Implementations§

Source§

impl Default for WitPrinter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<O> Freeze for WitPrinter<O>
where O: Freeze,

§

impl<O> RefUnwindSafe for WitPrinter<O>
where O: RefUnwindSafe,

§

impl<O> Send for WitPrinter<O>
where O: Send,

§

impl<O> Sync for WitPrinter<O>
where O: Sync,

§

impl<O> Unpin for WitPrinter<O>
where O: Unpin,

§

impl<O> UnwindSafe for WitPrinter<O>
where O: UnwindSafe,

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> 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, 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T