#[non_exhaustive]pub enum Target {
Djot,
Markdown,
Xml,
Html,
Asciidoc,
Runtime(RuntimeId),
}Expand description
Every format Twig can write — the output axis, as opposed to Format,
which is what Twig can parse.
Every Format is also a Target (use Target::from(format)), so the two
lists coincide today and the distinction costs nothing to ignore. It exists
because only one of them can grow freely: a Format must have a parser
behind it, while a target only needs somewhere for bytes to go. That makes an
export-only target — one Twig can write and no parser reads back, PDF being
the motivating case — expressible here and nowhere else. See the two format
axes in the Zig library’s DESIGN.md.
#[non_exhaustive] for exactly that reason: a future export-only variant is
then an additive change rather than a breaking one for callers that match on
this enum.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Djot
Markdown
Xml
Html
Asciidoc
AsciiDoc source, in Asciidoctor’s idiomatic spellings: = Title,
*strong* where the boundaries allow and **strong** where they do
not, [source,lang] listings, |=== tables, footnote:[] macros.
Runtime(RuntimeId)
A registered language, as a place to write to. Serializing to one that
declared no print is Error::UnsupportedFormat.
Implementations§
Source§impl Target
impl Target
Sourcepub fn as_format(self) -> Option<Format>
pub fn as_format(self) -> Option<Format>
The Format whose parser reads this target’s own output back, or
None for an export-only target.
Always Some today. It is the question to ask before assuming a target
can be round-tripped: None means bytes go out and nothing comes back,
so there is no “parse it again and compare” available for that target.
Sourcepub fn code(self) -> c_int
pub fn code(self) -> c_int
The C ABI’s code for this target. See Format::code.
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
The name this target answers to. See Format::name.
Trait Implementations§
impl Copy for Target
impl Eq for Target
Source§impl From<Format> for Target
Total: every input format is also an output target, even the ones with no
serializer yet (converting into XML reports Error::UnsupportedFormat
rather than being unnameable). A dialect lands on its language’s target —
Format::Commonmark and Format::Gfm both write as
Target::Markdown — so Target does not grow a row per dialect.
impl From<Format> for Target
Total: every input format is also an output target, even the ones with no
serializer yet (converting into XML reports Error::UnsupportedFormat
rather than being unnameable). A dialect lands on its language’s target —
Format::Commonmark and Format::Gfm both write as
Target::Markdown — so Target does not grow a row per dialect.
Source§impl From<Target> for TwigFormat
Panics on Target::Runtime; use Target::code.
impl From<Target> for TwigFormat
Panics on Target::Runtime; use Target::code.