Skip to main content

Module template

Module template 

Source
Expand description

SegmentTemplate identifier scanning and substitution (ISO/IEC 23009-1 5.3.9.4.4, Table 21).

The scan is strict: a $ that does not enclose a known identifier makes the whole template invalid, which the spec resolves by dropping the containing Representation (5.3.9.4.4 step 2). Format tags are %0<width>d only. Substitution reads the same scanned parts the validator builds, so a width is clamped once (to MAX_FORMAT_WIDTH) and $$ is read once.

Structs§

TemplateMatch
The identifiers a URL was matched against a template: the exact inverse of substitute.
TemplateUse
Which identifiers a template contains.

Enums§

TemplateError
Why substitute could not render a URL.
TemplateFault
Why a template is invalid.

Constants§

MAX_FORMAT_WIDTH
Cap on the %0Nd zero-padding width in a $Number$, $Time$ or $Bandwidth$ substitution. A u64 in decimal has at most 20 digits, so a wider padding is meaningless and a hostile $Number%9999999999d$ would allocate or loop unboundedly.

Functions§

format_width
n zero-padded to width digits (5.3.9.4.4 %0<width>d), the width clamped to 1..=MAX_FORMAT_WIDTH.
match_url
Recover the identifiers that substitute would have rendered as url.
scan
Scan template and report the identifiers it uses.
scan_initialization
Validate an initialization template: neither $Number$ nor $Time$.
scan_media
Validate a media/index template: exactly one of $Number$/$Time$.
substitute
Substitute the identifiers of an already scanned template.