package unstrctrd

  1. Overview
  2. Docs
Fast and compliant Unstructured parser according RFC 822

Install

Dune Dependency

Authors

Maintainers

Sources

unstrctrd-0.4.tbz
sha256=368a9b86acea988e952fe7bdf5db2c9eaf5345a6939e609351f15eeb25121824
sha512=94f68b5e1e9ae9c65ba3e4cb3e673d730a7fe9c4a2155f65373385d56a2eb0587657b73cea854f3cd44a020f67f391fe2cf0d6691f813b2fc093fd6ca64d1307

Description

Unstrctrd is a library for managing values formatted according to the unstructured rule introduced by RFC 822. This format can be found in emails, HTTP/1.1 and also in the description of Debian packages.

Published: 05 Apr 2024

README

Unstrctrd

An header of an email has a formal format described by RFC5322. After mrmime, it reveals that the more general form for any values of fields (like a date, an email address, etc.) is the unstructured form.

This library wants to provide the first ground of how to parse an email header. From that, we want to post-process unstructured values to cast them to any expected values like email address.

The idea behind this library is to handle a common format which can be found into several standards, the folding-whitespace. For example, the *.deb* file uses this kind of format where it's possible that one field can be associated to a multiline value.

Description: my superb Debian
 package!

This library wants to fold the value and, by this way, delete insignificant folding-whitespace to be able to apply a post-process like: parse an email address (eg. emile for more examples).

To: my.valid.mail
 (comment) @x25519.net
API

unstrctrd comes with several post-processes like:

  • val fold_fws : t -> t

  • val without_comments : t -> (t, [> error ]) result

  • val split_at : index:int -> t -> t * t

  • val split_on : on:[ WSP | FWS | Uchar of Uchar.t | Char of char | LF | CR ] -> t -> (t * t) option

Of course, it provides processes to manipulate a string and to convert an unstructured value to an UTF-8 string. With that, we can imply that unstrctrd handles UTF-8 encoding (and only UTF-8 according RFC 6532).

The API gives you a way to craft an unstructured value and ensures that this value is correct (and invalid any unstructured values which produces CRLF terminating token)

Angstrom

unstrctrd.parser provides an angstrom parser which can be safely composed with others angstrom parsers. It requires the allocation of an internal buffer used by ocamllex and ensure the safety.

Dependencies (4)

  1. angstrom >= "0.14.0"
  2. uutf
  3. dune >= "2.0"
  4. ocaml >= "4.07.0"

Dev Dependencies (7)

  1. crowbar >= "0.2" & with-test
  2. fmt with-test & >= "0.8.7"
  3. hxd with-test & >= "0.3.1"
  4. bigstringaf with-test
  5. ke with-test
  6. alcotest with-test
  7. rresult with-test

Conflicts

None