pub struct ByteTemplateBuf { /* private fields */ }Expand description
A parsed byte template that owns the source vector.
You can parse the template once and call Self::expand() multiple times.
This is generally more efficient than calling substitute() multiple times on the same string.
This template takes ownership of the source data.
If you do not need ownership, you can also use ByteTemplate to borrow it instead.
Depending on your application, that could prevent creating an unnecessary copy of the source data.
If you have a string instead of a byte slice,
you can use Template or TemplateBuf.
Implementations§
Source§impl ByteTemplateBuf
impl ByteTemplateBuf
Sourcepub fn from_vec(source: Vec<u8>) -> Result<Self, ParseError>
pub fn from_vec(source: Vec<u8>) -> Result<Self, ParseError>
Parse a template from a vector of bytes.
The source is can contain variables to be substituted later,
when you call Self::expand().
Variables have the form $NAME, ${NAME} or ${NAME:default}.
A variable name can only consist of ASCII letters, digits and underscores.
They are allowed to start with numbers.
You can escape dollar signs, backslashes, colons and braces with a backslash.
Sourcepub fn into_source(self) -> Vec<u8> ⓘ
pub fn into_source(self) -> Vec<u8> ⓘ
Consume the template to get the original source vector.
Sourcepub fn as_template<'a>(&'a self) -> &'a ByteTemplate<'a>
pub fn as_template<'a>(&'a self) -> &'a ByteTemplate<'a>
Borrow the template.