pub struct SectionInfo {
pub section_type: SectionType,
pub overall_position: usize,
pub template_position: Option<usize>,
pub content: Option<String>,
pub operations: Option<Vec<StringOp>>,
}Expand description
Detailed information about a template section for introspection and debugging.
Provides comprehensive metadata about each section in a template, including
its type, position, and content. Used by MultiTemplate::get_section_info
to enable programmatic template analysis and debugging.
This struct contains all necessary information to understand both the structure and content of template sections, making it useful for tools that need to analyze or manipulate templates programmatically.
§Field Details
section_type: Whether this is a literal text section or template operation sectionoverall_position: Zero-based position among all sections in the templatetemplate_position: Zero-based position among template sections only (None for literals)content: The literal text content (populated only for literal sections)operations: The operation sequence (populated only for template sections)
§Examples
use string_pipeline::{Template, SectionType};
let template = Template::parse("Name: {upper} | Age: {lower}").unwrap();
let sections = template.get_section_info();
// First section: "Name: "
assert_eq!(sections[0].section_type, SectionType::Literal);
assert_eq!(sections[0].overall_position, 0);
assert_eq!(sections[0].template_position, None);
assert_eq!(sections[0].content, Some("Name: ".to_string()));
assert!(sections[0].operations.is_none());
// Second section: {upper}
assert_eq!(sections[1].section_type, SectionType::Template);
assert_eq!(sections[1].overall_position, 1);
assert_eq!(sections[1].template_position, Some(0));
assert!(sections[1].content.is_none());
assert_eq!(sections[1].operations.as_ref().unwrap().len(), 1);Fields§
§section_type: SectionTypeThe type of this section (literal or template).
overall_position: usizePosition within all sections (both literal and template).
template_position: Option<usize>Position among template sections only (None for literal sections).
content: Option<String>Text content for literal sections (None for template sections).
operations: Option<Vec<StringOp>>Operations for template sections (None for literal sections).
Trait Implementations§
Source§impl Clone for SectionInfo
impl Clone for SectionInfo
Source§fn clone(&self) -> SectionInfo
fn clone(&self) -> SectionInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more