pub struct FormatString {
pub fragments: Vec<FormatFragment>,
}Expand description
A parsed format string.
Fields§
§fragments: Vec<FormatFragment>The FormatFragments that comprise the FormatString.
Implementations§
Source§impl FormatString
impl FormatString
Sourcepub const DEFAULT_NESTED_PREFIX: char = '$'
pub const DEFAULT_NESTED_PREFIX: char = '$'
Default prefix character for nested token specifiers.
Sourcepub fn format_for_platform<P: PlatformTypes>(
&self,
args: &[Arg],
style: FormatStyle,
) -> String
pub fn format_for_platform<P: PlatformTypes>( &self, args: &[Arg], style: FormatStyle, ) -> String
Formats a parsed format string with provided arguments using the specified
producing platform’s integer and pointer widths (P: PlatformTypes).
Sourcepub fn format(&self, args: &[Arg], style: FormatStyle) -> String
pub fn format(&self, args: &[Arg], style: FormatStyle) -> String
Formats a parsed format string with provided arguments.
Sourcepub fn format_with_errors<FE: FormatError>(
&self,
args: &[Result<Arg, FE::Error>],
style: FormatStyle,
error_formatter: &FE,
) -> String
pub fn format_with_errors<FE: FormatError>( &self, args: &[Result<Arg, FE::Error>], style: FormatStyle, error_formatter: &FE, ) -> String
Formats a parsed format string with the provided argument states (Result<Arg, FE::Error>),
delegating formatting of any failures, missing arguments, or type mismatches
to the provided FormatError implementation.
Sourcepub fn format_with_errors_for_platform<P: PlatformTypes, FE: FormatError>(
&self,
args: &[Result<Arg, FE::Error>],
style: FormatStyle,
error_formatter: &FE,
) -> String
pub fn format_with_errors_for_platform<P: PlatformTypes, FE: FormatError>( &self, args: &[Result<Arg, FE::Error>], style: FormatStyle, error_formatter: &FE, ) -> String
Formats a parsed format string with the provided argument states (Result<Arg, FE::Error>)
using the specified producing platform’s integer and pointer widths (P: PlatformTypes).
Sourcepub fn parse_printf(s: &str) -> Result<Self, String>
pub fn parse_printf(s: &str) -> Result<Self, String>
Parses a printf style format string using the default nested token prefix (‘$’).
Sourcepub fn parse_printf_with_prefix(s: &str, prefix: char) -> Result<Self, String>
pub fn parse_printf_with_prefix(s: &str, prefix: char) -> Result<Self, String>
Parses a printf style format string using a specified nested token prefix.
Sourcepub fn parse_pure_printf(s: &str) -> Result<Self, String>
pub fn parse_pure_printf(s: &str) -> Result<Self, String>
Parses a pure printf style format string without nested token parsing.
Sourcepub fn parse_printf_lossy(s: &str) -> Self
pub fn parse_printf_lossy(s: &str) -> Self
Parses a printf style format string infallibly using the default nested
token prefix ('$'), treating any invalid or incomplete % sequence as
a literal '%' and continuing to parse subsequent conversion specifiers
and nested tokens.
Sourcepub fn parse_printf_lossy_with_prefix(s: &str, prefix: char) -> Self
pub fn parse_printf_lossy_with_prefix(s: &str, prefix: char) -> Self
Parses a printf style format string infallibly using a specified nested
token prefix, treating any invalid or incomplete % sequence as a
literal '%' and continuing to parse subsequent conversion specifiers
and nested tokens.
Sourcepub fn parse_nested_tokens(s: &str) -> Self
pub fn parse_nested_tokens(s: &str) -> Self
Parses plain text containing nested token specifiers using the default prefix ('$'),
treating % characters as literal text rather than conversion specifiers.
Sourcepub fn parse_nested_tokens_with_prefix(s: &str, prefix: char) -> Self
pub fn parse_nested_tokens_with_prefix(s: &str, prefix: char) -> Self
Parses plain text containing nested token specifiers using a specified prefix,
treating % characters as literal text rather than conversion specifiers.
Sourcepub fn parse_core_fmt(s: &str) -> Result<Self, String>
pub fn parse_core_fmt(s: &str) -> Result<Self, String>
Parses a core::fmt style format string.