pub struct PromptSection {
pub name: String,
pub content: SectionContent,
pub cacheable: bool,
pub order: usize,
}Expand description
A prompt section with name, content, and cacheability
Fields§
§name: StringUnique section identifier
content: SectionContentSection content
cacheable: boolWhether this section should be cached (default: true for static)
order: usizeSection priority/order (lower = earlier in prompt)
Implementations§
Source§impl PromptSection
impl PromptSection
Sourcepub fn static_section(name: impl Into<String>, content: &'static str) -> Self
pub fn static_section(name: impl Into<String>, content: &'static str) -> Self
Create a new static section
Sourcepub fn dynamic_section<F>(name: impl Into<String>, compute: F) -> Self
pub fn dynamic_section<F>(name: impl Into<String>, compute: F) -> Self
Create a new dynamic section
Sourcepub fn cached_section(name: impl Into<String>, content: String) -> Self
pub fn cached_section(name: impl Into<String>, content: String) -> Self
Create a cached section (after computation)
Sourcepub fn with_order(self, order: usize) -> Self
pub fn with_order(self, order: usize) -> Self
Set section order
Sourcepub fn with_cacheable(self, cacheable: bool) -> Self
pub fn with_cacheable(self, cacheable: bool) -> Self
Set cacheability
Sourcepub fn compute_content(&self) -> String
pub fn compute_content(&self) -> String
Compute raw content (without section header)
Sourcepub fn estimated_tokens(&self) -> usize
pub fn estimated_tokens(&self) -> usize
Get estimated token count (approximate)
Trait Implementations§
Source§impl Clone for PromptSection
impl Clone for PromptSection
Source§fn clone(&self) -> PromptSection
fn clone(&self) -> PromptSection
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PromptSection
impl !RefUnwindSafe for PromptSection
impl Send for PromptSection
impl Sync for PromptSection
impl Unpin for PromptSection
impl UnsafeUnpin for PromptSection
impl !UnwindSafe for PromptSection
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