#[non_exhaustive]pub enum Target {
Djot,
Markdown,
Xml,
Html,
Asciidoc,
}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
Nameable, and always Error::UnsupportedFormat at the moment of
serializing — AsciiDoc has a parser and no serializer. Present for the
reason From<Format> for Target is
total: an input format Twig cannot write back is a runtime answer, not
an unnameable target.
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.
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).
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).