pub type FormatItem<'a> = BorrowedFormatItem<'a>;
👎Deprecated since 0.3.35: use BorrowedFormatItem instead for clarity
Expand description

A complete description of how to format and parse a type.

This alias exists for backwards-compatibility. It is recommended to use BorrowedFormatItem for clarity, as it is more explicit that the data is borrowed rather than owned.

Aliased Type§

enum FormatItem<'a> {
    Literal(&'a [u8]),
    Component(Component),
    Compound(&'a [BorrowedFormatItem<'a>]),
    Optional(&'a BorrowedFormatItem<'a>),
    First(&'a [BorrowedFormatItem<'a>]),
}

Variants§

§

Literal(&'a [u8])

Bytes that are formatted as-is.

Note: These bytes should be UTF-8, but are not required to be. The value is passed through String::from_utf8_lossy when necessary.

§

Component(Component)

A minimal representation of a single non-literal item.

§

Compound(&'a [BorrowedFormatItem<'a>])

A series of literals or components that collectively form a partial or complete description.

§

Optional(&'a BorrowedFormatItem<'a>)

A FormatItem that may or may not be present when parsing. If parsing fails, there will be no effect on the resulting struct.

This variant has no effect on formatting, as the value is guaranteed to be present.

§

First(&'a [BorrowedFormatItem<'a>])

A series of FormatItems where, when parsing, the first successful parse is used. When formatting, the first element of the slice is used. An empty slice is a no-op when formatting or parsing.

Trait Implementations§

source§

impl AnyFormatItem for BorrowedFormatItem<'_>

source§

fn parse_item<'a>( &self, parsed: &mut Parsed, input: &'a [u8] ) -> Result<&'a [u8], ParseFromDescription>

Parse a single item, returning the remaining input on success.
source§

impl<'a> Clone for BorrowedFormatItem<'a>

source§

fn clone(&self) -> BorrowedFormatItem<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BorrowedFormatItem<'_>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a [BorrowedFormatItem<'_>]> for BorrowedFormatItem<'a>

source§

fn from(items: &'a [BorrowedFormatItem<'_>]) -> Self

Converts to this type from the input type.
source§

impl From<Component> for BorrowedFormatItem<'_>

source§

fn from(component: Component) -> Self

Converts to this type from the input type.
source§

impl PartialEq<&[BorrowedFormatItem<'_>]> for BorrowedFormatItem<'_>

source§

fn eq(&self, rhs: &&[Self]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> PartialEq<BorrowedFormatItem<'a>> for BorrowedFormatItem<'a>

source§

fn eq(&self, other: &BorrowedFormatItem<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Component> for BorrowedFormatItem<'_>

source§

fn eq(&self, rhs: &Component) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sealed for BorrowedFormatItem<'_>

source§

fn parse_into<'a>( &self, input: &'a [u8], parsed: &mut Parsed ) -> Result<&'a [u8], Parse>

Parse the item into the provided Parsed struct. Read more
source§

fn parse(&self, input: &[u8]) -> Result<Parsed, Parse>

Parse the item into a new Parsed struct. Read more
source§

fn parse_date(&self, input: &[u8]) -> Result<Date, Parse>

Parse a Date from the format description.
source§

fn parse_time(&self, input: &[u8]) -> Result<Time, Parse>

Parse a Time from the format description.
source§

fn parse_offset(&self, input: &[u8]) -> Result<UtcOffset, Parse>

Parse a UtcOffset from the format description.
source§

fn parse_primitive_date_time( &self, input: &[u8] ) -> Result<PrimitiveDateTime, Parse>

Parse a PrimitiveDateTime from the format description.
source§

fn parse_offset_date_time(&self, input: &[u8]) -> Result<OffsetDateTime, Parse>

Parse a OffsetDateTime from the format description.
source§

impl Sealed for BorrowedFormatItem<'_>

source§

fn format_into( &self, output: &mut impl Write, date: Option<Date>, time: Option<Time>, offset: Option<UtcOffset> ) -> Result<usize, Format>

Format the item into the provided output, returning the number of bytes written.
source§

fn format( &self, date: Option<Date>, time: Option<Time>, offset: Option<UtcOffset> ) -> Result<String, Format>

Format the item directly to a String.
source§

impl<'a> TryFrom<Item<'a>> for BorrowedFormatItem<'a>

§

type Error = Error

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

fn try_from(item: Item<'a>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> Eq for BorrowedFormatItem<'a>

source§

impl Formattable for BorrowedFormatItem<'_>

source§

impl Parsable for BorrowedFormatItem<'_>

source§

impl<'a> StructuralEq for BorrowedFormatItem<'a>

source§

impl<'a> StructuralPartialEq for BorrowedFormatItem<'a>