pub(super) struct Formatter<'c, 'f, 't, 'w, W, L> {
pub(super) config: &'c Config<L>,
pub(super) fmt: &'f [u8],
pub(super) tm: &'t BrokenDownTime,
pub(super) wtr: &'w mut W,
}
Fields§
§config: &'c Config<L>
§fmt: &'f [u8]
§tm: &'t BrokenDownTime
§wtr: &'w mut W
Implementations§
Source§impl<'c, 'f, 't, 'w, W: Write, L: Custom> Formatter<'c, 'f, 't, 'w, W, L>
impl<'c, 'f, 't, 'w, W: Write, L: Custom> Formatter<'c, 'f, 't, 'w, W, L>
pub(super) fn format(&mut self) -> Result<(), Error>
fn format_one(&mut self) -> 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, Error>
fn utf8_decode_and_bump(&mut self) -> Result<char, Error>
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.
§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) -> u8
fn parse_colons(&mut self) -> u8
Parses an optional number of colons (up to 3) immediately before a conversion specifier.
Sourcefn fmt_iana_nocolon(&mut self) -> Result<(), Error>
fn fmt_iana_nocolon(&mut self) -> Result<(), Error>
%Q
Sourcefn fmt_iana_colon(&mut self) -> Result<(), Error>
fn fmt_iana_colon(&mut self) -> Result<(), Error>
%:Q
Sourcefn fmt_offset_nocolon(&mut self) -> Result<(), Error>
fn fmt_offset_nocolon(&mut self) -> Result<(), Error>
%z
Sourcefn fmt_offset_colon(&mut self) -> Result<(), Error>
fn fmt_offset_colon(&mut self) -> Result<(), Error>
%:z
Sourcefn fmt_offset_colon2(&mut self) -> Result<(), Error>
fn fmt_offset_colon2(&mut self) -> Result<(), Error>
%::z
Sourcefn fmt_offset_colon3(&mut self) -> Result<(), Error>
fn fmt_offset_colon3(&mut self) -> Result<(), Error>
%:::z