Skip to main content

Output

Struct Output 

Source
pub(crate) struct Output<W>
where W: ?Sized,
{ pub(crate) bytes_written: usize, pub(crate) output: W, }
Available on crate feature formatting only.
Expand description

An io::Writer that keeps track of the number of bytes written to it.

Fields§

§bytes_written: usize

The number of bytes written to the output.

§output: W

The output that bytes are written to.

Implementations§

Source§

impl<W> Output<W>
where W: Write + ?Sized,

Source

pub(super) fn format_iso8601_date<V, const CONFIG: EncodedConfig>( &mut self, value: &V, state: &mut V::State, ) -> Result<(), Format>

Format the date portion of ISO 8601.

Source

pub(super) fn format_iso8601_time<V, const CONFIG: EncodedConfig>( &mut self, value: &V, state: &mut V::State, ) -> Result<(), Format>

Format the time portion of ISO 8601.

Source

pub(super) fn format_iso8601_offset<V, const CONFIG: EncodedConfig>( &mut self, value: &V, state: &mut V::State, ) -> Result<(), Format>

Format the UTC offset portion of ISO 8601.

Source§

impl<W> Output<W>
where W: Write + ?Sized,

Source

pub(crate) fn write(&mut self, s: &str) -> Result<()>

Write all bytes to the output.

Source

pub(crate) fn write_bytes(&mut self, bytes: &[u8]) -> Result<()>

Write the string to the output.

Source

pub(crate) fn write_many<const N: usize>( &mut self, arr: [&str; N], ) -> Result<()>

Write all strings to the output (in order).

Source

pub(crate) fn write_if(&mut self, pred: bool, s: &str) -> Result<()>

Write the string to the output if and only if pred is true.

Source

pub(crate) fn write_if_else( &mut self, pred: bool, true_str: &str, false_str: &str, ) -> Result<()>

If and only if pred is true, write true_str to the output. Otherwise, write false_str.

Source

fn format_int_padded(&mut self, value: u64, width: u8) -> Result<()>

Write an integer with zeros as trailing padding if necessary to reach the requested width.

This function is intended to be used for formatting the fractional part of a value, as the trailing zeros would change the semantic meaning for non-fractional values.

Source

pub(crate) fn format_float( &mut self, value: f64, digits_before_decimal: u8, digits_after_decimal: Option<NonZero<u8>>, ) -> Result<()>

Write the floating point number to the output.

This method accepts the number of digits before and after the decimal. The value will be padded with zeroes to the left if necessary.

Source

pub(crate) fn format_single_digit(&mut self, value: ru8<0, 9>) -> Result<()>

Format a single digit.

Source

pub(crate) fn format_two_digits( &mut self, value: ru8<0, 99>, padding: Padding, ) -> Result<()>

Format a two digit number with the specified padding.

Source

pub(crate) fn format_three_digits( &mut self, value: ru16<0, 999>, padding: Padding, ) -> Result<()>

Format a three digit number with the specified padding.

Source

pub(crate) fn format_four_digits( &mut self, value: ru16<0, 9_999>, padding: Padding, ) -> Result<()>

Format a four digit number with the specified padding.

Source

pub(crate) fn format_four_digits_pad_zero( &mut self, value: ru16<0, 9_999>, ) -> Result<()>

Format a four digit number that is padded with zeroes.

Source

pub(crate) fn format_five_digits_pad_zero( &mut self, value: ru32<0, 99_999>, ) -> Result<()>

Format a five digit number that is padded with zeroes.

Source

pub(crate) fn format_six_digits_pad_zero( &mut self, value: ru32<0, 999_999>, ) -> Result<()>

Format a six digit number that is padded with zeroes.

Source

pub(crate) fn format_u64_pad_none(&mut self, value: u64) -> Result<()>

Format a number with no padding.

If the sign is mandatory, the sign must be written by the caller.

Source

pub(crate) fn format_u128_pad_none(&mut self, value: u128) -> Result<()>

Format a number with no padding.

If the sign is mandatory, the sign must be written by the caller.

Source

fn fmt_day(&mut self, day: ru8<1, 31>, _: Day) -> Result<(), Error>

Format the day into the designated output.

Source

fn fmt_month_short(&mut self, month: Month, _: MonthShort) -> Result<()>

Format the month into the designated output using the abbreviated name.

Source

fn fmt_month_long(&mut self, month: Month, _: MonthLong) -> Result<()>

Format the month into the designated output using the full name.

Source

fn fmt_month_numerical(&mut self, month: Month, _: MonthNumerical) -> Result<()>

Format the month into the designated output as a number from 1-12.

Source

fn fmt_ordinal( &mut self, ordinal: ru16<1, 366>, _: Ordinal, ) -> Result<(), Error>

Format the ordinal into the designated output.

Source

fn fmt_weekday_short(&mut self, weekday: Weekday, _: WeekdayShort) -> Result<()>

Format the weekday into the designated output using the abbreviated name.

Source

fn fmt_weekday_long(&mut self, weekday: Weekday, _: WeekdayLong) -> Result<()>

Format the weekday into the designated output using the full name.

Source

fn fmt_weekday_sunday( &mut self, weekday: Weekday, _: WeekdaySunday, ) -> Result<()>

Format the weekday into the designated output as a number from either 0-6 or 1-7 (depending on the modifier), where Sunday is either 0 or 1.

Source

fn fmt_weekday_monday( &mut self, weekday: Weekday, _: WeekdayMonday, ) -> Result<()>

Format the weekday into the designated output as a number from either 0-6 or 1-7 (depending on the modifier), where Monday is either 0 or 1.

Source

fn fmt_week_number_iso( &mut self, week_number: ru8<1, 53>, _: WeekNumberIso, ) -> Result<()>

Source

fn fmt_week_number_sunday( &mut self, week_number: ru8<0, 53>, _: WeekNumberSunday, ) -> Result<()>

Source

fn fmt_week_number_monday( &mut self, week_number: ru8<0, 53>, _: WeekNumberMonday, ) -> Result<()>

Source

fn fmt_calendar_year_full_extended_range( &mut self, full_year: ri32<-999_999, 999_999>, _: CalendarYearFullExtendedRange, ) -> Result<()>

Source

fn fmt_calendar_year_full_standard_range( &mut self, full_year: ri16<-9_999, 9_999>, _: CalendarYearFullStandardRange, ) -> Result<()>

Source

fn fmt_iso_year_full_extended_range( &mut self, full_year: ri32<-999_999, 999_999>, _: IsoYearFullExtendedRange, ) -> Result<()>

Source

fn fmt_iso_year_full_standard_range( &mut self, year: ri16<-9_999, 9_999>, _: IsoYearFullStandardRange, ) -> Result<()>

Source

fn fmt_calendar_year_century_extended_range( &mut self, century: ri16<-9_999, 9_999>, is_negative: bool, _: CalendarYearCenturyExtendedRange, ) -> Result<()>

Source

fn fmt_calendar_year_century_standard_range( &mut self, century: ri8<-99, 99>, is_negative: bool, _: CalendarYearCenturyStandardRange, ) -> Result<()>

Source

fn fmt_iso_year_century_extended_range( &mut self, century: ri16<-9_999, 9_999>, is_negative: bool, _: IsoYearCenturyExtendedRange, ) -> Result<()>

Source

fn fmt_iso_year_century_standard_range( &mut self, century: ri8<-99, 99>, is_negative: bool, _: IsoYearCenturyStandardRange, ) -> Result<()>

Source

fn fmt_calendar_year_last_two( &mut self, last_two: ru8<0, 99>, _: CalendarYearLastTwo, ) -> Result<()>

Source

fn fmt_iso_year_last_two( &mut self, last_two: ru8<0, 99>, _: IsoYearLastTwo, ) -> Result<()>

Source

fn fmt_hour_12(&mut self, hour: ru8<0, { _ }>, _: Hour12) -> Result<()>

Format the hour into the designated output using the 12-hour clock.

Source

fn fmt_hour_24(&mut self, hour: ru8<0, { _ }>, _: Hour24) -> Result<()>

Format the hour into the designated output using the 24-hour clock.

Source

fn fmt_minute(&mut self, minute: ru8<0, { _ }>, _: Minute) -> Result<(), Error>

Format the minute into the designated output.

Source

fn fmt_period(&mut self, period: Period, _: Period) -> Result<(), Error>

Format the period into the designated output.

Source

fn fmt_second(&mut self, second: ru8<0, { _ }>, _: Second) -> Result<(), Error>

Format the second into the designated output.

Source

fn fmt_subsecond( &mut self, nanos: ru32<0, { _ }>, _: Subsecond, ) -> Result<(), Error>

Format the subsecond into the designated output.

Source

fn fmt_sign(&mut self, is_negative: bool, sign_is_mandatory: bool) -> Result<()>

Source

fn fmt_offset_hour( &mut self, is_negative: bool, hour: ri8<-25, 25>, _: OffsetHour, ) -> Result<(), Error>

Format the offset hour into the designated output.

Source

fn fmt_offset_minute( &mut self, offset_minute: ri8<{ _ }, { _ }>, _: OffsetMinute, ) -> Result<(), Error>

Format the offset minute into the designated output.

Source

fn fmt_offset_second( &mut self, offset_second: ri8<{ _ }, { _ }>, _: OffsetSecond, ) -> Result<(), Error>

Format the offset second into the designated output.

Source

fn fmt_unix_timestamp_second( &mut self, timestamp: i64, _: UnixTimestampSecond, ) -> Result<(), Error>

Format the Unix timestamp (in seconds) into the designated output.

Source

fn fmt_unix_timestamp_millisecond( &mut self, timestamp_millis: i64, _: UnixTimestampMillisecond, ) -> Result<(), Error>

Format the Unix timestamp (in milliseconds) into the designated output.

Source

fn fmt_unix_timestamp_microsecond( &mut self, timestamp_micros: i128, _: UnixTimestampMicrosecond, ) -> Result<(), Error>

Format the Unix timestamp (in microseconds) into the designated output.

Source

fn fmt_unix_timestamp_nanosecond( &mut self, timestamp_nanos: i128, _: UnixTimestampNanosecond, ) -> Result<(), Error>

Format the Unix timestamp (in nanoseconds) into the designated output.

Trait Implementations§

Source§

impl<W> Debug for Output<W>
where W: ?Sized + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> Freeze for Output<W>
where W: Freeze + ?Sized,

§

impl<W> RefUnwindSafe for Output<W>
where W: RefUnwindSafe + ?Sized,

§

impl<W> Send for Output<W>
where W: Send + ?Sized,

§

impl<W> Sync for Output<W>
where W: Sync + ?Sized,

§

impl<W> Unpin for Output<W>
where W: Unpin + ?Sized,

§

impl<W> UnsafeUnpin for Output<W>
where W: UnsafeUnpin + ?Sized,

§

impl<W> UnwindSafe for Output<W>
where W: UnwindSafe + ?Sized,

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> SizeHint for T
where T: ?Sized,

Source§

default fn lower_bound(&self) -> usize

🔬This is a nightly-only experimental API. (core_io_internals)
Returns a lower bound on the number of elements this container-like item contains. For example, an array [u8; 12] could return any value between 0 and 12 inclusively as a correct implementation. Read more
Source§

default fn upper_bound(&self) -> Option<usize>

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an upper bound on the number of elements this container-like item contains if it can be determined, otherwise None. Read more
Source§

final fn size_hint(&self) -> (usize, Option<usize>)

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an estimate for the number of elements this container like type contains. Read more
Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)]
const SIZE: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGNMENT: Alignment = _

🔬This is a nightly-only experimental API. (ptr_alignment_type)
Source§

#[doc(hidden)]
const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)]
const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.