DocumentPrinter

Struct DocumentPrinter 

Source
pub struct DocumentPrinter<'a, W: Write> { /* private fields */ }
Expand description

A printer for WAC documents.

Implementations§

Source§

impl<'a, W: Write> DocumentPrinter<'a, W>

Source

pub fn new(writer: W, source: &'a str, space: Option<&'static str>) -> Self

Creates a new document printer for the given write.

If space is None, then the printer will use four spaces for indentation.

Source

pub fn document(&mut self, doc: &Document<'_>) -> Result

Prints the given document.

Source

pub fn package_directive(&mut self, directive: &PackageDirective<'_>) -> Result

Prints the given package directive.

Source

pub fn statement(&mut self, statement: &Statement<'_>) -> Result

Prints the given statement.

Source

pub fn docs(&mut self, docs: &[DocComment<'_>]) -> Result

Prints the given doc comments.

Source

pub fn import_statement(&mut self, statement: &ImportStatement<'_>) -> Result

Prints the given import statement.

Source

pub fn import_type(&mut self, ty: &ImportType<'_>) -> Result

Prints the given import type.

Source

pub fn package_path(&mut self, path: &PackagePath<'_>) -> Result

Prints the given package path.

Source

pub fn func_type(&mut self, ty: &FuncType<'_>) -> Result

Prints the given function type.

Source

pub fn ty(&mut self, ty: &Type<'_>) -> Result

Prints the given type.

Source

pub fn inline_interface(&mut self, iface: &InlineInterface<'_>) -> Result

Prints the given inline interface.

Source

pub fn interface_item(&mut self, item: &InterfaceItem<'_>) -> Result

Prints the given interface export.

Source

pub fn use_type(&mut self, use_ty: &Use<'_>) -> Result

Prints the given use type.

Source

pub fn use_path(&mut self, path: &UsePath<'_>) -> Result

Prints the given use path.

Source

pub fn item_type_decl(&mut self, decl: &ItemTypeDecl<'_>) -> Result

Prints the given type declaration.

Source

pub fn resource_decl(&mut self, decl: &ResourceDecl<'_>) -> Result

Prints the given resource declaration.

Source

pub fn resource_method(&mut self, method: &ResourceMethod<'_>) -> Result

Prints the given resource method.

Source

pub fn constructor(&mut self, constructor: &Constructor<'_>) -> Result

Prints the given constructor.

Source

pub fn method(&mut self, method: &Method<'_>) -> Result

Prints the given method.

Source

pub fn func_type_ref(&mut self, ty: &FuncTypeRef<'_>) -> Result

Prints the given function type reference.

Source

pub fn variant_decl(&mut self, decl: &VariantDecl<'_>) -> Result

Prints the given variant declaration.

Source

pub fn variant_case(&mut self, case: &VariantCase<'_>) -> Result

Prints the given variant case.

Source

pub fn record_decl(&mut self, decl: &RecordDecl<'_>) -> Result

Prints the given record declaration.

Source

pub fn flags_decl(&mut self, decl: &FlagsDecl<'_>) -> Result

Prints the given flags declaration.

Source

pub fn enum_decl(&mut self, decl: &EnumDecl<'_>) -> Result

Prints the given enum declaration.

Source

pub fn type_alias(&mut self, alias: &TypeAlias<'_>) -> Result

Prints the given type alias.

Source

pub fn interface_export(&mut self, export: &InterfaceExport<'_>) -> Result

Prints the given interface export.

Source

pub fn type_statement(&mut self, stmt: &TypeStatement<'_>) -> Result

Prints the given type statement.

Source

pub fn interface_decl(&mut self, decl: &InterfaceDecl<'_>) -> Result

Prints the given interface declaration.

Source

pub fn world_decl(&mut self, decl: &WorldDecl<'_>) -> Result

Prints the given world declaration.

Source

pub fn world_item(&mut self, item: &WorldItem<'_>) -> Result

Prints the given world item.

Source

pub fn world_import(&mut self, import: &WorldImport<'_>) -> Result

Prints the given world import.

Source

pub fn world_export(&mut self, export: &WorldExport<'_>) -> Result

Prints the given world export.

Source

pub fn world_item_path(&mut self, path: &WorldItemPath<'_>) -> Result

Prints the given world item path.

Source

pub fn named_world_item(&mut self, item: &NamedWorldItem<'_>) -> Result

Prints the given named world item.

Source

pub fn extern_type(&mut self, ty: &ExternType<'_>) -> Result

Prints the given extern type.

Source

pub fn world_include(&mut self, include: &WorldInclude<'_>) -> Result

Prints the given world include.

Source

pub fn world_ref(&mut self, reference: &WorldRef<'_>) -> Result

Prints the given world reference.

Source

pub fn type_decl(&mut self, decl: &TypeDecl<'_>) -> Result

Prints the given type declaration.

Source

pub fn let_statement(&mut self, stmt: &LetStatement<'_>) -> Result

Prints the given let statement.

Source

pub fn expr(&mut self, expr: &Expr<'_>) -> Result

Prints the given expression.

Source

pub fn primary_expr(&mut self, expr: &PrimaryExpr<'_>) -> Result

Prints the given primary expression.

Source

pub fn new_expr(&mut self, expr: &NewExpr<'_>) -> Result

Prints the given new expression.

Source

pub fn postfix_expr(&mut self, expr: &PostfixExpr<'_>) -> Result

Prints the given postfix expression.

Source

pub fn access_expr(&mut self, expr: &AccessExpr<'_>) -> Result

Prints the given access expression.

Source

pub fn named_access_expr(&mut self, expr: &NamedAccessExpr<'_>) -> Result

Prints the given named access expression.

Source

pub fn export_statement(&mut self, stmt: &ExportStatement<'_>) -> Result

Prints the given export statement.

Auto Trait Implementations§

§

impl<'a, W> Freeze for DocumentPrinter<'a, W>
where W: Freeze,

§

impl<'a, W> RefUnwindSafe for DocumentPrinter<'a, W>
where W: RefUnwindSafe,

§

impl<'a, W> Send for DocumentPrinter<'a, W>
where W: Send,

§

impl<'a, W> Sync for DocumentPrinter<'a, W>
where W: Sync,

§

impl<'a, W> Unpin for DocumentPrinter<'a, W>
where W: Unpin,

§

impl<'a, W> UnwindSafe for DocumentPrinter<'a, W>
where W: 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,