pub enum TemplatePart {
Lit(String),
Var(String),
Time(String),
Cmd(Vec<TemplatePart>),
Any(Vec<TemplatePart>),
}
Expand description
Parts that make up a Template
. You can have literal strings, variables, time date format, command, or optional format with OPTIONAL_RENDER_CHAR
.
TemplatePart::Lit
= Literal Strings like "hi "
in "hi {name}"
TemplatePart::Var
= Variable part like "name"
in "hi {name}"
TemplatePart::Time
= Date time format like "%F"
in "Today: {%F}"
TemplatePart::Cmd
= Command like "echo world"
in "hello $(echo world)"
TemplatePart::Any
= Optional format like "name?age"
in "hello {name?age}"
TemplatePart::Cmd
and TemplatePart::Any
can in turn contain other TemplatePart
inside them. Haven’t tested on nesting complex ones within each other though.
Variants§
Lit(String)
Literal string, keep them as they are
Var(String)
Variables, use the variable’s value in the rendered String
Time(String)
DateTime format, use chrono::Local
in the given format
Cmd(Vec<TemplatePart>)
Shell Command, use the output of command in the rendered String
Any(Vec<TemplatePart>)
Multiple variables or TemplatePart
s, use the first one that succeeds
Trait Implementations§
source§impl Clone for TemplatePart
impl Clone for TemplatePart
source§fn clone(&self) -> TemplatePart
fn clone(&self) -> TemplatePart
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more