Trait Output

Source
pub trait Output {
Show 15 methods // Required methods fn push_str(&mut self, src: &str); fn indent_if_needed(&mut self) -> bool; fn indent_start(&mut self); fn indent_end(&mut self); fn newline(&mut self); // Provided methods fn indent_and_print(&mut self, src: &str) { ... } fn keyword(&mut self, src: &str) { ... } fn ty(&mut self, src: &str, _kind: TypeKind) { ... } fn param(&mut self, src: &str) { ... } fn case(&mut self, src: &str) { ... } fn generic_args_start(&mut self) { ... } fn generic_args_end(&mut self) { ... } fn doc(&mut self, doc: &str) { ... } fn semicolon(&mut self) { ... } fn str(&mut self, src: &str) { ... }
}
Expand description

Trait defining visitor methods driven by WitPrinter.

Some methods in this trait have default implementations. These default implementations may rely on helper functions that are not invoked directly by WitPrinter.

Required Methods§

Source

fn push_str(&mut self, src: &str)

Push a string slice into a buffer or an output.

Parameter src can contain punctation characters, and must be escaped when outputing to languages like HTML. Helper function used exclusively by the default implementations of trait methods. This function is not called directly by WitPrinter. When overriding all the trait methods, users do not need to handle this function.

Source

fn indent_if_needed(&mut self) -> bool

Set the appropriate indentation.

Helper function used exclusively by the default implementations of trait methods. This function is not called directly by WitPrinter. When overriding all the trait methods, users do not need to handle this function.

Source

fn indent_start(&mut self)

Start of indentation. In WIT this represents {\n.

Source

fn indent_end(&mut self)

End of indentation. In WIT this represents }\n.

Source

fn newline(&mut self)

A newline is added.

Provided Methods§

Source

fn indent_and_print(&mut self, src: &str)

This method is designed to be used only by the default methods of this trait. Called only from the default implementation functions of this trait.

Source

fn keyword(&mut self, src: &str)

A keyword is added. Keywords are hardcoded strings from [a-z], but can start with @ when printing a Feature Gate

Source

fn ty(&mut self, src: &str, _kind: TypeKind)

A type is added.

Source

fn param(&mut self, src: &str)

A parameter name of a function, record or a named return is added.

Source

fn case(&mut self, src: &str)

A case belonging to a variant, enum or flags is added.

Source

fn generic_args_start(&mut self)

Generic argument section starts. In WIT this represents the < character.

Source

fn generic_args_end(&mut self)

Generic argument section ends. In WIT this represents the ‘>’ character.

Source

fn doc(&mut self, doc: &str)

Called when a single documentation line is added. The doc parameter starts with /// omitted, and can be an empty string.

Source

fn semicolon(&mut self)

A semicolon is added.

Source

fn str(&mut self, src: &str)

Any string that does not have a specialized function is added. Parameter src can contain punctation characters, and must be escaped when outputing to languages like HTML.

Implementors§