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§
Sourcefn push_str(&mut self, src: &str)
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.
Sourcefn indent_if_needed(&mut self) -> bool
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.
Sourcefn indent_start(&mut self)
fn indent_start(&mut self)
Start of indentation. In WIT this represents {\n
.
Sourcefn indent_end(&mut self)
fn indent_end(&mut self)
End of indentation. In WIT this represents }\n
.
Provided Methods§
Sourcefn indent_and_print(&mut self, src: &str)
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.
Sourcefn keyword(&mut self, src: &str)
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
Sourcefn param(&mut self, src: &str)
fn param(&mut self, src: &str)
A parameter name of a function, record or a named return is added.
Sourcefn generic_args_start(&mut self)
fn generic_args_start(&mut self)
Generic argument section starts. In WIT this represents the <
character.
Sourcefn generic_args_end(&mut self)
fn generic_args_end(&mut self)
Generic argument section ends. In WIT this represents the ‘>’ character.