Formatter

Struct Formatter 

Source
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>

Source

pub(super) fn format(&mut self) -> Result<(), Error>

Source

fn format_one(&mut self, ext: &Extension) -> Result<(), Error>

Source

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.

Source

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.

Source

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.

Source

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.)

Source

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.)

Source

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.

Source

fn parse_colons(&mut self) -> Result<u8, Error>

Parses an optional number of colons (up to 3) immediately before a conversion specifier.

Source

fn write_item(&mut self, ext: &Extension, item: &Item) -> Result<(), Error>

Source

fn fmt_ampm_lower(&self) -> Result<ItemString, Error>

%P

Source

fn fmt_ampm_upper(&self, ext: &Extension) -> Result<ItemString, Error>

%p

Source

fn fmt_american_date(&mut self) -> Result<Item, Error>

%D

Source

fn fmt_clock_nosecs(&mut self) -> Result<Item, Error>

%R

Source

fn fmt_clock_secs(&mut self) -> Result<Item, Error>

%T

Source

fn fmt_iso_date(&mut self) -> Result<Item, Error>

%F

Source

fn fmt_day_zero(&self) -> Result<ItemInteger, Error>

%d

Source

fn fmt_day_space(&self) -> Result<ItemInteger, Error>

%e

Source

fn fmt_hour12_zero(&self) -> Result<ItemInteger, Error>

%I

Source

fn fmt_hour24_zero(&self) -> Result<ItemInteger, Error>

%H

Source

fn fmt_hour12_space(&self) -> Result<ItemInteger, Error>

%l

Source

fn fmt_hour24_space(&self) -> Result<ItemInteger, Error>

%k

Source

fn fmt_minute(&self) -> Result<ItemInteger, Error>

%M

Source

fn fmt_month(&self) -> Result<ItemInteger, Error>

%m

Source

fn fmt_month_full(&self) -> Result<ItemString, Error>

%B

Source

fn fmt_month_abbrev(&self) -> Result<ItemString, Error>

%b, %h

Source

fn fmt_iana_nocolon(&mut self) -> Result<Item, Error>

%Q

Source

fn fmt_iana_colon(&mut self) -> Result<Item, Error>

%:Q

Source

fn fmt_offset_nocolon(&self) -> Result<ItemOffset, Error>

%z

Source

fn fmt_offset_colon(&self) -> Result<ItemOffset, Error>

%:z

Source

fn fmt_offset_colon2(&self) -> Result<ItemOffset, Error>

%::z

Source

fn fmt_offset_colon3(&self) -> Result<ItemOffset, Error>

%:::z

Source

fn fmt_second(&self) -> Result<ItemInteger, Error>

%S

Source

fn fmt_timestamp(&self) -> Result<ItemInteger, Error>

%s

Source

fn fmt_fractional(&self, ext: &Extension) -> Result<Item, Error>

%f

Source

fn fmt_dot_fractional(&self, ext: &Extension) -> Result<Item, Error>

%.f

Source

fn fmt_nanoseconds(&self, ext: &Extension) -> Result<Item, Error>

%N

Source

fn fmt_tzabbrev(&mut self, ext: &Extension) -> Result<Item, Error>

%Z

Source

fn fmt_weekday_full(&self) -> Result<ItemString, Error>

%A

Source

fn fmt_weekday_abbrev(&self) -> Result<ItemString, Error>

%a

Source

fn fmt_weekday_mon(&self) -> Result<ItemInteger, Error>

%u

Source

fn fmt_weekday_sun(&self) -> Result<ItemInteger, Error>

%w

Source

fn fmt_week_sun(&self) -> Result<ItemInteger, Error>

%U

Source

fn fmt_week_iso(&self) -> Result<ItemInteger, Error>

%V

Source

fn fmt_week_mon(&self) -> Result<ItemInteger, Error>

%W

Source

fn fmt_year(&self) -> Result<ItemInteger, Error>

%Y

Source

fn fmt_year2(&self) -> Result<ItemInteger, Error>

%y

Source

fn fmt_century(&self) -> Result<ItemInteger, Error>

%C

Source

fn fmt_iso_week_year(&self) -> Result<ItemInteger, Error>

%G

Source

fn fmt_iso_week_year2(&self) -> Result<ItemInteger, Error>

%g

Source

fn fmt_quarter(&self) -> Result<ItemInteger, Error>

%q

Source

fn fmt_day_of_year(&self) -> Result<ItemInteger, Error>

%j

Source

fn fmt_literal(&self, literal: &'static str) -> Result<ItemString, Error>

%n, %t

Source

fn fmt_datetime(&mut self, ext: &Extension) -> Result<Item, Error>

%c

Source

fn fmt_date(&mut self, ext: &Extension) -> Result<Item, Error>

%x

Source

fn fmt_time(&mut self, ext: &Extension) -> Result<Item, Error>

%X

Source

fn fmt_12hour_time(&mut self, ext: &Extension) -> Result<Item, Error>

%r

Auto Trait Implementations§

§

impl<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L> Freeze for Formatter<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L>

§

impl<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L> !RefUnwindSafe for Formatter<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L>

§

impl<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L> !Send for Formatter<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L>

§

impl<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L> !Sync for Formatter<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L>

§

impl<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L> Unpin for Formatter<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L>

§

impl<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L> !UnwindSafe for Formatter<'config, 'fmt, 'tm, 'writer, 'buffer, 'data, 'write, L>

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, 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.