Module coap_numbers::content_format

source ·
Expand description

Functions for accessing CoAP Content Format numbers

Unlike the other modules, these are not expressed as constants, for the plain reason that their syntax is so far from Rust’s that the names would become unwieldy (eg. text/plain; charset=utf-8 has several characters that’d all be coalesced into underscores by rules like those applied for option numbers, and that’s not even getting started with the ones that have quotes in them).

Instead, const functions are provided. The intention is to use them in such a way that the big list of strings is only ever used at compile time.

§Maintenance note

This module’s workhorse functions are sourced through files that are generated by a Python script (registry-content/build-content-formats.py) triggered by a Makefile in the same directory, and fed from IANA’s published registry CSV.

This process in intentionally only run manually, and its output is checked in to git. This ensures that on every change, there is manual review (especially if new exotic characters show up), that incompatible changes can be managed (although that’s not that much of an issue as no constants are exported from this module), and that the build process does not depend on online infrastructure.

Functions§

  • Match a content format string representation against the list of known content formats.
  • Turn a content format number into a content format string