package mrmime

  1. Overview
  2. Docs

Module Mrmime.HdSource

Sourcetype decoder

Type of decoder.

Sourcetype decode = [
  1. | `Field of Field.field Location.with_location
  2. | `Await
  3. | `End of string
  4. | `Malformed of string
]
Sourceval decoder : ?p:Field.witness Field_name.Map.t -> Bigstringaf.t -> decoder

decoder ?p buf returns a decoder with a set of field-name binded with expected kind of value. When the decoder will decode value of a given field-name, it will try to extract expected value describe by the given Field.witness or it returns a Unstructured.t.

Sourceval decode : decoder -> decode

decode decoder is:

  • `Field field when extracted a field.
  • `Await when the decoder wants more input.
  • `End trailer when we reach end of the header. trailer is what the user gaves which is not the part of the header.
  • `Malformed err we we reach an error while decoding.
Sourceval src : decoder -> string -> int -> int -> (unit, [> Rresult.R.msg ]) result

src decoder src off len gives more input to decoder. The function can fail when given input is bigger than internal buffer of decoder (see decoder).

OCaml

Innovation. Community. Security.