[][src]Trait media_type_impl_utils::quoted_string::MimeParsingExt

pub trait MimeParsingExt: ParsingImpl {
    const ALLOW_UTF8: bool;
    const OBS: bool;

    fn custom_state(state: FWSState, emit: bool) -> (State<Self>, bool);

    fn handle_normal_state(
        bch: PartialCodePoint
    ) -> Result<(State<Self>, bool), CoreError> { ... } }

This is an extension trait for implementing MediaType parsing in context of Mime

Associated Constants

const ALLOW_UTF8: bool

is true if utf8 is allowed

const OBS: bool

is true if the obs- part of the grammar is supported

Loading content...

Required methods

fn custom_state(state: FWSState, emit: bool) -> (State<Self>, bool)

crate the custom state based on the FWSState state and emit

Example

This example is not tested
fn custom_state(state: FWSState, emit: bool) -> (State<Self>, bool) {
    (State::Custom(MyCustomType(state)), emit)
}
Loading content...

Provided methods

fn handle_normal_state(
    bch: PartialCodePoint
) -> Result<(State<Self>, bool), CoreError>

default impl. to handle the normal state of the State automaton

It works following:

  1. return Ok((State::Normal, true)) if it is qtext in context of Self::ALLOW_UTF8 and Self::OBS
  2. return Ok(Self::custom_state(FWSState::HitCr, false)) if the input was '\r'
  3. else return Err(CoreError::InvalidChar)

Note if Self::ALLOW_UTF8 is set to true any bch.as_u8() > 0x7f will be treated as non-us-ascii utf8. This state machine does not validated if it is valid utf8 so if it is used on a byte sequence which is not known to be a valid utf8 string it is still necessary to validate if it is utf8 and not e.g. latin1.

Loading content...

Implementors

impl MimeParsingExt for MimeObsParsing[src]

impl MimeParsingExt for MimeObsParsingUtf8[src]

impl MimeParsingExt for MimeParsing[src]

impl MimeParsingExt for MimeParsingUtf8[src]

Loading content...