pub trait CoreFmtFormatMacroGenerator {
    // Required methods
    fn finalize(self, format_string: String) -> Result<TokenStream>;
    fn string_fragment(&mut self, string: &str) -> Result<()>;
    fn integer_conversion(
        &mut self,
        ty: Ident,
        expression: Arg
    ) -> Result<Option<String>>;
    fn string_conversion(&mut self, expression: Arg) -> Result<Option<String>>;
    fn char_conversion(&mut self, expression: Arg) -> Result<Option<String>>;

    // Provided method
    fn untyped_conversion(&mut self, _expression: Arg) -> Result<()> { ... }
}
Expand description

A specialized generator for proc macros that produce core::fmt style format strings.

For proc macros that need to translate a pw_format invocation into a core::fmt style format string, CoreFmtFormatMacroGenerator offer a specialized form of FormatMacroGenerator that builds the format string and provides it as an argument to finalize.

In cases where a generator needs to override the conversion specifier (i.e. {}, it can return it from its appropriate conversion method.

Required Methods§

source

fn finalize(self, format_string: String) -> Result<TokenStream>

Called by generate_core_fmt at the end of code generation.

Works like FormatMacroGenerator::finalize with the addition of being provided a core::fmt format string.

source

fn string_fragment(&mut self, string: &str) -> Result<()>

Process a string fragment.

NOTE: This string may contain unescaped { and } characters. However, most implementations of this train can simply ignore string fragments as they will be included (with properly escaped { and } characters) as part of the format string passed to CoreFmtFormatMacroGenerator::finalize.

See FormatMacroGenerator::string_fragment for a disambiguation between a string fragment and string conversion.

source

fn integer_conversion( &mut self, ty: Ident, expression: Arg ) -> Result<Option<String>>

Process an integer conversion.

source

fn string_conversion(&mut self, expression: Arg) -> Result<Option<String>>

Process a string conversion.

source

fn char_conversion(&mut self, expression: Arg) -> Result<Option<String>>

Process a character conversion.

Provided Methods§

source

fn untyped_conversion(&mut self, _expression: Arg) -> Result<()>

Process an untyped conversion.

Implementors§