pub struct RunnerBuilder<S: VariableStorage> { /* private fields */ }Expand description
Builds a Runner with optional saliency, provider, and host-function
configuration in a single fluent chain.
Use this when you need to customise at least one of those at construction
time; for the zero-config case Runner::new is still the fastest path.
§Example
use bubbles::{HashMapStorage, RunnerBuilder, Value, compile};
use bubbles::saliency::BestLeastRecentlyViewed;
let prog = compile("title: A\n---\nHello.\n===\n").unwrap();
let mut runner = RunnerBuilder::new(prog, HashMapStorage::new())
.with_saliency(BestLeastRecentlyViewed::default())
.with_function("greet", |_args| Ok(Value::Text("hi".into())))
.build();
runner.start("A").unwrap();Implementations§
Source§impl<S: VariableStorage> RunnerBuilder<S>
impl<S: VariableStorage> RunnerBuilder<S>
Sourcepub fn new(program: Program, storage: S) -> Self
pub fn new(program: Program, storage: S) -> Self
Creates a builder with defaults matching Runner::new:
FirstAvailable saliency and PassthroughProvider.
Sourcepub fn with_saliency(self, strategy: impl SaliencyStrategy) -> Self
pub fn with_saliency(self, strategy: impl SaliencyStrategy) -> Self
Overrides the saliency strategy used for line and node group selection.
Sourcepub fn with_provider(self, provider: impl LineProvider) -> Self
pub fn with_provider(self, provider: impl LineProvider) -> Self
Overrides the line provider used for localisation lookup.
Sourcepub fn with_function<F>(self, name: &str, f: F) -> Self
pub fn with_function<F>(self, name: &str, f: F) -> Self
Registers a host function available to dialogue expressions.
This is a convenience wrapper around
FunctionLibrary::register that keeps configuration on the builder
rather than requiring a post-construction library_mut() call.
Sourcepub fn build(self) -> Runner<S>
pub fn build(self) -> Runner<S>
Consumes the builder and returns a fully configured Runner.
The runner is in the Idle state; call Runner::start to begin
execution.