Format
in package
The three forms' names on the wire and on disk, and a cheap test of whether a body is worth decoding as one -- DXN.md §6, mirroring `Dextrin.Format`, so every implementation answers the same.
identifies() is a prefix test, not a parse: true means "worth
attempting", never "valid". Its text rule mainly tells DXN from JSON in
a body that comes without a type, so it accepts only what JSON cannot
start with: after whitespace, comments and an optional header, a % --
a map, a struct or a schema document. A list or a scalar is DXN too, but
it overlaps with JSON, and stays unrecognised on purpose (Jan,
2026-10-20).
Table of Contents
Methods
- extension() : string
- The file extension of `$form`, with its dot.
- form() : Form|null
- The form `$mediaType` names: one of the three, or text for any type with a structured `+dxn` suffix (`application/vnd.acme.event+dxn`); null for anything else. There is no `+dxnb` suffix. Media types compare without regard to case; the caller strips any parameters (`; charset=...`) first.
- identifies() : bool
- Whether `$body` is worth decoding as `$form`. Binary: the envelope's magic, `DX`, and a version byte (DXN.md §2.1). Text and schemas: after whitespace (commas included), `#` comments and an optional `@dxn "..."` header, the first character is `%`.
- mediaType() : string
- The media type of `$form`.
- __construct() : mixed
- skipTrivia() : string
- `$text` without its leading whitespace and comments.
Methods
extension()
The file extension of `$form`, with its dot.
public
static extension(Form $form) : string
Parameters
- $form : Form
Return values
stringform()
The form `$mediaType` names: one of the three, or text for any type with a structured `+dxn` suffix (`application/vnd.acme.event+dxn`); null for anything else. There is no `+dxnb` suffix. Media types compare without regard to case; the caller strips any parameters (`; charset=...`) first.
public
static form(string $mediaType) : Form|null
Parameters
- $mediaType : string
Return values
Form|nullidentifies()
Whether `$body` is worth decoding as `$form`. Binary: the envelope's magic, `DX`, and a version byte (DXN.md §2.1). Text and schemas: after whitespace (commas included), `#` comments and an optional `@dxn "..."` header, the first character is `%`.
public
static identifies(string $body, Form $form) : bool
Parameters
- $body : string
- $form : Form
Return values
boolmediaType()
The media type of `$form`.
public
static mediaType(Form $form) : string
Parameters
- $form : Form
Return values
string__construct()
private
__construct() : mixed
skipTrivia()
`$text` without its leading whitespace and comments.
private
static skipTrivia(string $text) : string
Parameters
- $text : string