pub struct TemplateManager { /* private fields */ }Expand description
Manages a collection of named prompt templates.
Implementations§
Source§impl TemplateManager
impl TemplateManager
Sourcepub fn load_from_dir(dir: &Path) -> Result<Self>
pub fn load_from_dir(dir: &Path) -> Result<Self>
Load all .md files from a directory as templates.
Each file becomes a template named after the file (without extension). Returns an error only if the directory cannot be read.
Sourcepub fn render(&self, name: &str, vars: HashMap<&str, &str>) -> Result<String>
pub fn render(&self, name: &str, vars: HashMap<&str, &str>) -> Result<String>
Render a template by name with the given variables.
Sourcepub fn get(&self, name: &str) -> Option<&PromptTemplate>
pub fn get(&self, name: &str) -> Option<&PromptTemplate>
Get a template by name.
Sourcepub fn template_names(&self) -> Vec<&str>
pub fn template_names(&self) -> Vec<&str>
List all loaded template names.
Trait Implementations§
Source§impl Clone for TemplateManager
impl Clone for TemplateManager
Source§fn clone(&self) -> TemplateManager
fn clone(&self) -> TemplateManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TemplateManager
impl Debug for TemplateManager
Source§impl Default for TemplateManager
impl Default for TemplateManager
Source§fn default() -> TemplateManager
fn default() -> TemplateManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TemplateManager
impl RefUnwindSafe for TemplateManager
impl Send for TemplateManager
impl Sync for TemplateManager
impl Unpin for TemplateManager
impl UnsafeUnpin for TemplateManager
impl UnwindSafe for TemplateManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().