SectionInfo

Struct SectionInfo 

Source
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 section
  • overall_position: Zero-based position among all sections in the template
  • template_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: SectionType

The type of this section (literal or template).

§overall_position: usize

Position 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

Source§

fn clone(&self) -> SectionInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SectionInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.