Type Alias yaml_rust2::yaml::YAMLDecodingTrapFn

source ·
pub type YAMLDecodingTrapFn = fn(malformation_length: u8, bytes_read_after_malformation: u8, input_at_malformation: &[u8], output: &mut String) -> ControlFlow<Cow<'static, str>>;
Expand description

The signature of the function to call when using YAMLDecodingTrap::Call.

The arguments are as follows:

  • malformation_length: The length of the sequence the decoder failed to decode.
  • bytes_read_after_malformation: The number of lookahead bytes the decoder consumed after the malformation.
  • input_at_malformation: What the input buffer is at the malformation. This is the buffer starting at the malformation. The first malformation_length bytes are the problematic sequence. The following bytes_read_after_malformation are already stored in the decoder and will not be re-fed.
  • output: The output string.

The function must modify output as it feels is best. For instance, one could recreate the behavior of YAMLDecodingTrap::Ignore with an empty function, YAMLDecodingTrap::Replace by pushing a \u{FFFD} into output and YAMLDecodingTrap::Strict by returning ControlFlow::Break.

§Returns

The function must return ControlFlow::Continue if decoding may continue or ControlFlow::Break if decoding must be aborted. An optional error string may be supplied.