pub struct Template {
pub content: String,
pub name: String,
pub slots: HashMap<String, Slot>,
pub metadata: TemplateMetadata,
}Expand description
Represents a template with AI injection slots.
Fields§
§content: StringOriginal template content.
name: StringName of this template.
slots: HashMap<String, Slot>Slots found in the template.
metadata: TemplateMetadataTemplate metadata.
Implementations§
Source§impl Template
impl Template
Sourcepub fn with_metadata(self, metadata: TemplateMetadata) -> Self
pub fn with_metadata(self, metadata: TemplateMetadata) -> Self
Set template metadata.
Sourcepub fn with_slot(
self,
name: impl Into<String>,
prompt: impl Into<String>,
) -> Self
pub fn with_slot( self, name: impl Into<String>, prompt: impl Into<String>, ) -> Self
Add a slot definition with a custom prompt.
§Arguments
name- Slot name (must match a slot in the template)prompt- The AI prompt for generating code
Sourcepub fn configure_slot(self, slot: Slot) -> Self
pub fn configure_slot(self, slot: Slot) -> Self
Configure a slot with detailed options.
Sourcepub fn find_locations(&self) -> Vec<SlotLocation>
pub fn find_locations(&self) -> Vec<SlotLocation>
Find all slot locations in the template.
Sourcepub fn render(&self, injections: &HashMap<String, String>) -> Result<String>
pub fn render(&self, injections: &HashMap<String, String>) -> Result<String>
Render the template with provided code injections.
§Arguments
injections- Map of slot names to generated code
Sourcepub fn slot_names(&self) -> Vec<&str>
pub fn slot_names(&self) -> Vec<&str>
Get a list of slot names.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Template
impl<'de> Deserialize<'de> for Template
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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 more