[−][src]Trait media_type_impl_utils::quoted_string::MimeParsingExt
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
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) }
Provided methods
fn handle_normal_state(
bch: PartialCodePoint
) -> Result<(State<Self>, bool), CoreError>
bch: PartialCodePoint
) -> Result<(State<Self>, bool), CoreError>
default impl. to handle the normal state of the State
automaton
It works following:
- return
Ok((State::Normal, true))
if it is qtext in context ofSelf::ALLOW_UTF8
andSelf::OBS
- return
Ok(Self::custom_state(FWSState::HitCr, false))
if the input was'\r'
- 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.