Struct ContentSection

Source
pub struct ContentSection {
    pub title: String,
    pub content: String,
    pub priority: u8,
    pub truncated: bool,
}
Expand description

A content section with associated metadata for prioritization.

Represents a section of content (like project metadata, source code, or documentation) with a title, content, priority level, and truncation status.

§Priority Levels

  • 9-10: High priority (metadata, documentation)
  • 5-6: Medium priority (AST analysis, structure)
  • 1-2: Low priority (source code)

§Examples

use ai_context_gen::token_counter::ContentSection;

// Create a high-priority section
let section = ContentSection::high_priority(
    "Project Metadata".to_string(),
    "Important project information...".to_string()
);

// Create a custom priority section
let custom = ContentSection::new(
    "Custom Section".to_string(),
    "Content here...".to_string(),
    7
);

Fields§

§title: String

Title of the content section.

§content: String

The actual content of the section.

§priority: u8

Priority level (higher numbers = higher priority).

§truncated: bool

Whether this section was truncated to fit token limits.

Implementations§

Source§

impl ContentSection

Source

pub fn new(title: String, content: String, priority: u8) -> Self

Creates a new content section with the specified priority.

§Arguments
  • title - Display title for the section
  • content - The content text
  • priority - Priority level (0-255, higher is more important)
§Examples
use ai_context_gen::token_counter::ContentSection;

let section = ContentSection::new(
    "My Section".to_string(),
    "Section content...".to_string(),
    8
);
Source

pub fn high_priority(title: String, content: String) -> Self

Creates a high-priority content section (priority 9).

Use for critical content like project metadata and documentation that should always be included.

§Arguments
  • title - Display title for the section
  • content - The content text
Source

pub fn medium_priority(title: String, content: String) -> Self

Creates a medium-priority content section (priority 5).

Use for structural information like AST analysis and project organization.

§Arguments
  • title - Display title for the section
  • content - The content text
Source

pub fn low_priority(title: String, content: String) -> Self

Creates a low-priority content section (priority 1).

Use for detailed content like complete source code that can be truncated if necessary.

§Arguments
  • title - Display title for the section
  • content - The content text

Trait Implementations§

Source§

impl Clone for ContentSection

Source§

fn clone(&self) -> ContentSection

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 ContentSection

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.