pub(super) struct Formatter<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L> {
pub(super) config: &'config Config<L>,
pub(super) fmt: &'fmt [u8],
pub(super) tm: &'tm BrokenDownTime,
pub(super) wtr: &'writer mut BorrowedWriter<'buffer, 'data, 'write>,
}Fields§
§config: &'config Config<L>§fmt: &'fmt [u8]§tm: &'tm BrokenDownTime§wtr: &'writer mut BorrowedWriter<'buffer, 'data, 'write>Implementations§
Source§impl<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L: Custom> Formatter<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L>
impl<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L: Custom> Formatter<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L>
pub(super) fn format(&mut self) -> Result<(), Error>
fn format_one(&mut self, ext: &Extension) -> Result<(), Error>
Sourcefn f(&self) -> u8
fn f(&self) -> u8
Returns the byte at the current position of the format string.
§Panics
This panics when the entire format string has been consumed.
Sourcefn bump_fmt(&mut self) -> bool
fn bump_fmt(&mut self) -> bool
Bumps the position of the format string.
This returns true in precisely the cases where self.f() will not
panic. i.e., When the end of the format string hasn’t been reached yet.
Sourcefn utf8_decode_and_bump(&mut self) -> Result<char, FE>
fn utf8_decode_and_bump(&mut self) -> Result<char, FE>
Decodes a Unicode scalar value from the beginning of fmt and advances
the parser accordingly.
If a Unicode scalar value could not be decoded, then an error is returned.
It would be nice to just pass through bytes as-is instead of doing
actual UTF-8 decoding, but since the Write trait only represents
Unicode-accepting buffers, we need to actually do decoding here.
§Errors
Unless lenient parsing is enabled, this returns an error if UTF-8 decoding failed. When lenient parsing is enabled, decoding errors are turned into the Unicode replacement codepoint via the “substitution of maximal subparts” strategy.
§Panics
When self.fmt is empty. i.e., Only call this when you know there is
some remaining bytes to parse.
Sourcefn parse_extension(&mut self) -> Result<Extension, Error>
fn parse_extension(&mut self) -> Result<Extension, Error>
Parses optional extensions before a specifier directive. That is, right
after the %. If any extensions are parsed, the parser is bumped
to the next byte. (If no next byte exists, then an error is returned.)
Sourcefn parse_flag(&mut self) -> Result<Option<Flag>, Error>
fn parse_flag(&mut self) -> Result<Option<Flag>, Error>
Parses an optional flag. And if one is parsed, the parser is bumped to the next byte. (If no next byte exists, then an error is returned.)
Sourcefn parse_width(&mut self) -> Result<Option<u8>, Error>
fn parse_width(&mut self) -> Result<Option<u8>, Error>
Parses an optional width that comes after a (possibly absent) flag and before the specifier directive itself. And if a width is parsed, the parser is bumped to the next byte. (If no next byte exists, then an error is returned.)
Note that this is also used to parse precision settings for %f and
%.f. In the former case, the width is just re-interpreted as a
precision setting. In the latter case, something like %5.9f is
technically valid, but the 5 is ignored.
Sourcefn parse_colons(&mut self) -> Result<u8, Error>
fn parse_colons(&mut self) -> Result<u8, Error>
Parses an optional number of colons (up to 3) immediately before a conversion specifier.
fn write_item(&mut self, ext: &Extension, item: &Item) -> Result<(), Error>
Sourcefn fmt_ampm_lower(&self) -> Result<ItemString, Error>
fn fmt_ampm_lower(&self) -> Result<ItemString, Error>
%P
Sourcefn fmt_ampm_upper(&self, ext: &Extension) -> Result<ItemString, Error>
fn fmt_ampm_upper(&self, ext: &Extension) -> Result<ItemString, Error>
%p
Sourcefn fmt_american_date(&mut self) -> Result<Item, Error>
fn fmt_american_date(&mut self) -> Result<Item, Error>
%D
Sourcefn fmt_clock_nosecs(&mut self) -> Result<Item, Error>
fn fmt_clock_nosecs(&mut self) -> Result<Item, Error>
%R
Sourcefn fmt_clock_secs(&mut self) -> Result<Item, Error>
fn fmt_clock_secs(&mut self) -> Result<Item, Error>
%T
Sourcefn fmt_iso_date(&mut self) -> Result<Item, Error>
fn fmt_iso_date(&mut self) -> Result<Item, Error>
%F
Sourcefn fmt_day_zero(&self) -> Result<ItemInteger, Error>
fn fmt_day_zero(&self) -> Result<ItemInteger, Error>
%d
Sourcefn fmt_day_space(&self) -> Result<ItemInteger, Error>
fn fmt_day_space(&self) -> Result<ItemInteger, Error>
%e
Sourcefn fmt_hour12_zero(&self) -> Result<ItemInteger, Error>
fn fmt_hour12_zero(&self) -> Result<ItemInteger, Error>
%I
Sourcefn fmt_hour24_zero(&self) -> Result<ItemInteger, Error>
fn fmt_hour24_zero(&self) -> Result<ItemInteger, Error>
%H
Sourcefn fmt_hour12_space(&self) -> Result<ItemInteger, Error>
fn fmt_hour12_space(&self) -> Result<ItemInteger, Error>
%l
Sourcefn fmt_hour24_space(&self) -> Result<ItemInteger, Error>
fn fmt_hour24_space(&self) -> Result<ItemInteger, Error>
%k
Sourcefn fmt_minute(&self) -> Result<ItemInteger, Error>
fn fmt_minute(&self) -> Result<ItemInteger, Error>
%M
Sourcefn fmt_month(&self) -> Result<ItemInteger, Error>
fn fmt_month(&self) -> Result<ItemInteger, Error>
%m
Sourcefn fmt_month_full(&self) -> Result<ItemString, Error>
fn fmt_month_full(&self) -> Result<ItemString, Error>
%B
Sourcefn fmt_month_abbrev(&self) -> Result<ItemString, Error>
fn fmt_month_abbrev(&self) -> Result<ItemString, Error>
%b, %h
Sourcefn fmt_iana_nocolon(&mut self) -> Result<Item, Error>
fn fmt_iana_nocolon(&mut self) -> Result<Item, Error>
%Q
Sourcefn fmt_iana_colon(&mut self) -> Result<Item, Error>
fn fmt_iana_colon(&mut self) -> Result<Item, Error>
%:Q
Sourcefn fmt_offset_nocolon(&self) -> Result<ItemOffset, Error>
fn fmt_offset_nocolon(&self) -> Result<ItemOffset, Error>
%z
Sourcefn fmt_offset_colon(&self) -> Result<ItemOffset, Error>
fn fmt_offset_colon(&self) -> Result<ItemOffset, Error>
%:z
Sourcefn fmt_offset_colon2(&self) -> Result<ItemOffset, Error>
fn fmt_offset_colon2(&self) -> Result<ItemOffset, Error>
%::z
Sourcefn fmt_offset_colon3(&self) -> Result<ItemOffset, Error>
fn fmt_offset_colon3(&self) -> Result<ItemOffset, Error>
%:::z
Sourcefn fmt_second(&self) -> Result<ItemInteger, Error>
fn fmt_second(&self) -> Result<ItemInteger, Error>
%S
Sourcefn fmt_timestamp(&self) -> Result<ItemInteger, Error>
fn fmt_timestamp(&self) -> Result<ItemInteger, Error>
%s
Sourcefn fmt_weekday_full(&self) -> Result<ItemString, Error>
fn fmt_weekday_full(&self) -> Result<ItemString, Error>
%A
Sourcefn fmt_weekday_abbrev(&self) -> Result<ItemString, Error>
fn fmt_weekday_abbrev(&self) -> Result<ItemString, Error>
%a
Sourcefn fmt_weekday_mon(&self) -> Result<ItemInteger, Error>
fn fmt_weekday_mon(&self) -> Result<ItemInteger, Error>
%u
Sourcefn fmt_weekday_sun(&self) -> Result<ItemInteger, Error>
fn fmt_weekday_sun(&self) -> Result<ItemInteger, Error>
%w
Sourcefn fmt_week_sun(&self) -> Result<ItemInteger, Error>
fn fmt_week_sun(&self) -> Result<ItemInteger, Error>
%U
Sourcefn fmt_week_iso(&self) -> Result<ItemInteger, Error>
fn fmt_week_iso(&self) -> Result<ItemInteger, Error>
%V
Sourcefn fmt_week_mon(&self) -> Result<ItemInteger, Error>
fn fmt_week_mon(&self) -> Result<ItemInteger, Error>
%W
Sourcefn fmt_year(&self) -> Result<ItemInteger, Error>
fn fmt_year(&self) -> Result<ItemInteger, Error>
%Y
Sourcefn fmt_year2(&self) -> Result<ItemInteger, Error>
fn fmt_year2(&self) -> Result<ItemInteger, Error>
%y
Sourcefn fmt_century(&self) -> Result<ItemInteger, Error>
fn fmt_century(&self) -> Result<ItemInteger, Error>
%C
Sourcefn fmt_iso_week_year(&self) -> Result<ItemInteger, Error>
fn fmt_iso_week_year(&self) -> Result<ItemInteger, Error>
%G
Sourcefn fmt_iso_week_year2(&self) -> Result<ItemInteger, Error>
fn fmt_iso_week_year2(&self) -> Result<ItemInteger, Error>
%g
Sourcefn fmt_quarter(&self) -> Result<ItemInteger, Error>
fn fmt_quarter(&self) -> Result<ItemInteger, Error>
%q
Sourcefn fmt_day_of_year(&self) -> Result<ItemInteger, Error>
fn fmt_day_of_year(&self) -> Result<ItemInteger, Error>
%j
Sourcefn fmt_literal(&self, literal: &'static str) -> Result<ItemString, Error>
fn fmt_literal(&self, literal: &'static str) -> Result<ItemString, Error>
%n, %t