pub struct StreamingExpand { /* private fields */ }Expand description
Streaming template expansion state machine.
Processes input bytes incrementally, expanding {{ env:KEY }} placeholders.
At most MAX_PLACEHOLDER_SCAN bytes are held in buffer. Plain text streams
flush immediately with zero buffering.
Implementations§
Source§impl StreamingExpand
impl StreamingExpand
Sourcepub fn new(
overrides: &[(String, String)],
env: &HashMap<String, String>,
) -> Self
pub fn new( overrides: &[(String, String)], env: &HashMap<String, String>, ) -> Self
Create with env vars and optional explicit overrides. Overrides take precedence over env vars.
Sourcepub fn with_vars(self, vars: &HashMap<String, Value>) -> Self
pub fn with_vars(self, vars: &HashMap<String, Value>) -> Self
Create with env vars, structured variables, and optional explicit overrides.
Enables key-path evaluation in template tags (e.g., {{ pkg.package.name }}).
Sourcepub fn with_call_resolver(self, resolver: PlaceholderCall) -> Self
pub fn with_call_resolver(self, resolver: PlaceholderCall) -> Self
Enable {{ MODULE::FUNC(args) }} calls, dispatched through resolver.
Args are $var.path references, string, int, float, and bool
literals, or {key: value} and [item] literals nesting those
same shapes. Unknown functions and bad arity fail strict at expansion.
Sourcepub fn process_bytes(
&mut self,
input: &[u8],
out: &mut Vec<u8>,
) -> Result<usize>
pub fn process_bytes( &mut self, input: &[u8], out: &mut Vec<u8>, ) -> Result<usize>
Process a chunk of input bytes, writing expanded output to out.
Returns early on empty input to preserve pending boundary state.
Sourcepub fn flush(self, out: &mut Vec<u8>) -> Result<()>
pub fn flush(self, out: &mut Vec<u8>) -> Result<()>
Flush remaining buffer. Incomplete placeholders are treated as literals.
Sourcepub fn expand_string(self, input: &str) -> Result<String>
pub fn expand_string(self, input: &str) -> Result<String>
Process a complete string (convenience for short command arguments).