Struct OutputToString

Source
pub struct OutputToString { /* private fields */ }
Expand description

Helper structure to help maintain an indentation level when printing source, modeled after the support in wit-bindgen-core. Indentation is set to two spaces.

Trait Implementations§

Source§

impl Default for OutputToString

Source§

fn default() -> OutputToString

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

impl Display for OutputToString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<OutputToString> for String

Source§

fn from(output: OutputToString) -> String

Converts to this type from the input type.
Source§

impl Output for OutputToString

Source§

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

Push a string slice into a buffer or an output. Read more
Source§

fn indent_if_needed(&mut self) -> bool

Set the appropriate indentation. Read more
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.
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.

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

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

Source§

impl<T> MaybeSendSync for T